{"id":25865,"date":"2018-05-04T03:15:34","date_gmt":"2018-05-04T08:15:34","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=25865"},"modified":"2022-06-03T03:35:04","modified_gmt":"2022-06-03T08:35:04","slug":"how-to-fix-the-leverage-browser-caching-warning-in-wordpress","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-fix-the-leverage-browser-caching-warning-in-wordpress\/","title":{"rendered":"How to Fix the “Leverage Browser Caching” Warning in WordPress"},"content":{"rendered":"
<\/p>\n
We will show you How to Fix the “Leverage Browser Caching” Warning in WordPress, on a Linux based virtual private server<\/a>. Leverage Browser Caching is a warning which you may encounter if you run a speed or performance test for your website using some of the tools which are available online.\u00a0When you are running a speed or performance test for your WordPress website using some online test tool like Google PageSpeed Insights<\/a> for example, you may encounter a warning message that says you don’t have enabled browser caching for your website. Every time your browser loads a page it needs to download all the web resources to display that page properly. This includes resources like HTML files, CSS, JavaScript or images. So, fetching those resources over and over could be slow and expensive. By enabling Leverage Browser Caching<\/strong> you can specify whether some of the resources can be cached and by whom, for how long the resource can be cached, and how it can be revalidated when the caching policy expires.<\/p>\n By enabling Leverage Browser Caching the page load times can be significantly improved for all your returning visitors, particularly, for those who re-visit same areas of your website.<\/p>\n First, you need to find out whether your WordPress site is powered by Apache or Nginx. If you are running Apache web server on your Linux VPS<\/a>, you can log in to your server and edit the In case you are running Nginx on your Linux VPS, add the following lines in the server block for your WordPress website:<\/p>\n Do not forget to restart Nginx so the changes can take effect:<\/p>\n Once you enable Leverage Browser Caching for your WordPress website, you can use Google PageSpeed Insights or some of the other page speed tools which are available online to check the status. Now the page speed tool will show you that Leverage Browser Caching for your WordPress website enabled.<\/p>\n Of course, you don\u2019t have to fix the Leverage Browser Caching Warning in WordPress, if you use one of our Managed WordPress\u00a0 VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to fix the Leverage Browser Caching Warning in WordPress 4 for you. They are available 24\u00d77 and will take care of your request immediately.<\/p>\n PS<\/strong><\/span>. If you liked this post on how to fix the Leverage Browser Caching Warning in WordPress, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":" We will show you How to Fix the “Leverage Browser Caching” Warning in WordPress, on a Linux based virtual private … <\/p>\n
\n<\/p>\nWhat is browser caching exactly?<\/h2>\n
How do you fix the “Leverage Browser Caching” Warning in WordPress?<\/h2>\n
.htaccess<\/code> file for your WordPress website. Add the following lines:<\/p>\n
## EXPIRES CACHING ##\r\n<IfModule mod_expires.c>\r\nExpiresActive On\r\nExpiresByType image\/jpg \"access plus 1 year\"\r\nExpiresByType image\/jpeg \"access plus 1 year\"\r\nExpiresByType image\/gif \"access plus 1 year\"\r\nExpiresByType image\/png \"access plus 1 year\"\r\nExpiresByType text\/css \"access plus 1 month\"\r\nExpiresByType application\/pdf \"access plus 1 month\"\r\nExpiresByType text\/x-javascript \"access plus 1 month\"\r\nExpiresByType application\/x-shockwave-flash \"access plus 1 month\"\r\nExpiresByType image\/x-icon \"access plus 1 year\"\r\nExpiresDefault \"access plus 2 days\"\r\n<\/IfModule>\r\n## EXPIRES CACHING ##\r\n<\/pre>\n
# Enable browser caching\r\n location ~* \\.(jpg|jpeg|png|gif|ico|css|js)$ {\r\n expires 7d;\r\n}\r\n<\/pre>\n
sudo service nginx restart<\/pre>\n