How To: Leverage Browser Caching in WordPress Without Plugins

In this post we will tell you how easily you can leverage browser caching in wordpress without plugins and increase your site pagespeed score instantly.

Many of us already know this, that the browsers we all use contains cached resources of the various webpages we visit daily, which are stored on our computer and still we don’t take advantage of this. Expert webmasters and bloggers use this idea to further improve their blog load speed to deliver content fast and quickly without much delay.

If you have ever checked out your Google PageSpeed score, you would have seen a high priority telling you to leverage browser caching, now lets see how you can make that warning go away.

Leverage browser caching in wordpress without plugins - Google pagespeed

Please click on image to enlarge

Being a WordPress user you might be very familiar with WP Super Cache and W3 Total Cache which are great caching plugins for your blog and are highly recommended. But they too come with a little bit of cons such as they use large amount of plugin files to enable caching and also they are server hungry, so if you are on a shared hosting plan, you might also incur site downtime because of so many memory requests.

Don’t worry you can still leverage browser caching without the use of Plugins and keep your blog load times fast as well. So here is the code which you have to put in your .htaccess file.


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

Your .htaccess file will be located in the root folder of your website. Just login to your hosting FTP account and search for htaccess. If you still can’t find the file, the file maybe hidden, especially if your host is Dreamhost. In that case just download a free FTP client such as FileZilla, and then access your site files from there.

Leverage browser caching in wordpress without plugins - htaccess file

Note 1: By default, htaccess file permissions is set to 644, so before editing the file, change the permissions to 777 which will give you full read/write access. Be sure to change it back to 644 after you have completed making the changes.

Note 2: If you are already using the WordPress SEO plugin by Yoast, you can edit the htaccess file right from WordPress itself. Just click on the SEO tab in the sidebar and then select the Edit files option. Here paste the code and click on Save changes.

After making all the changes, just check your Google Pagespeed score by visiting Pagespeed Insights or you can also use other tools such as Pingdom or YSlow to make sure everything is working fine and the browser is caching your site files.

Congratulations, now your site is being cached by the browsers. These cached files include all the static images, CSS stylesheets, javascript files and all other resources which are loaded by default in each of your site’s webpages. So the next time you visit your site, these files will be retrieved from your computer rather than the server and your site will serve to your customer requests faster.

If you get stuck somewhere be sure to let me know in the comments. For more such tutorials, please subscribe to our feed.

Source: thomasgriffinmedia

Subscribe to our Weekly Newsletter

I take your privacy very seriously


  1. shraqs Reply

    Will it effect the adsense javascript code?

  2. digimanain? Reply

    Thanks for the tutorial. It helps to increase my page speed :D

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail.