How to Fix the “Leverage Browser Caching” Warning in WordPress

How to Fix the Leverage Browser Caching Warning in WordPress

We will show you How to Fix the “Leverage Browser Caching” Warning in WordPress, on a Linux based virtual private server. 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. When you are running a speed or performance test for your WordPress website using some online test tool like Google PageSpeed Insights for example, you may encounter a warning message that says you don’t have enabled browser caching for your website.

What is browser caching exactly?

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 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.

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.

How do you fix the “Leverage Browser Caching” Warning in WordPress?

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, you can log in to your server and edit the .htaccess file for your WordPress website. Add the following lines:

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##

In case you are running Nginx on your Linux VPS, add the following lines in the server block for your WordPress website:

# Enable browser caching
    location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
        expires 7d;
}

Do not forget to restart Nginx so the changes can take effect:

sudo service nginx restart

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.

Of course, you don’t have to fix the Leverage Browser Caching Warning in WordPress, if you use one of our Managed WordPress  VPS Hosting 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×7 and will take care of your request immediately.

PS. 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.

Leave a Comment