How to Leverage Browser Caching

Add these rules to your .htaccess file in order to reduce the load times of web pages by storing commonly used files from your website on your visitors browser.

 

If you want a lightning-fast WordPress website, check out our free eBook WordPress Speed Optimization Ebook! In it you will find a variety of easy-to-follow tips to improve the speed of your site!

19 Comments

  1. Reply December 24, 2015 / 18:30 PratikNBorkarSiteGround Team

    we can also use Cache plugin like W3 total cahe to avoid this

  2. Reply June 10, 2016 / 14:19 Stefany BaezSiteGround Team

    I have found this works way better than W3. That plugin, though amazing, seems to be in constant conflict with other plugins and/or themes. Some people will actually see their sites performance decrease when using it. I go for this code, the plugin has done amazing disasters to my site before.

  3. Reply June 16, 2016 / 04:25 JodiSiteGround Team

    I added this to my .htaccess file, purched my cache, then ran gtmetrix and it still says I need to leverage browser caching. Any ideas?

    • Reply June 16, 2016 / 07:35 Ivan StefanovSiteGround Team

      Jodi, you should check the exact resources that doesn't have leverage browser caching according to gtmetric and verify that they are indeed loaded by your site and that for their content/type is added "ExpiresByType" rule. If you have difficulties doing that, please submit a support ticket and my colleagues will address this issue for you.

  4. Reply October 5, 2016 / 06:12 QasimSiteGround Team

    Which plugins are better for my sites w3 total cache or super cache? plz suggest. these are my sites

    http://fhmpakistan.com/
    http://monthlybrands.com.pk/

    • Reply October 6, 2016 / 13:24 Ivan StefanovSiteGround Team

      Qasim, we recommend you our SuperCacher plugin as it has been developed especially for our infrastructure and the technology behind the plugin should have a positive impact to the overall page speed of your sites. SuperCacher provides 3 or 4 caching levels, depending of the hosting plan you have, and you can take advantage of static caching, dynamic page caching and object caching (memcached). The fourth layer is HHVM available to our Cloud servers.

  5. Reply October 10, 2016 / 18:32 abojadSiteGround Team

    oh , and can i use WP SUPER CASH with supercasher from sg ? or i have to just enable one plugin ?!

    • Reply October 13, 2016 / 14:05 Ivan YordanovSiteGround Team

      We recommend to use only one plugin for full page caching. Practically, using 2 different plugins for the same thing won't speed up your site further.

      There is no issue however, to use one plugin for full page caching, another one for CSS/JS minifying and a third one for Memcached.

  6. Reply October 22, 2016 / 19:46 OgnjenSiteGround Team

    This helps me a lot with my websites. There is always a problem with cashing.

  7. Reply October 25, 2016 / 14:39 M Zeeshan HaiderSiteGround Team

    Hi i want to fast my website loading time, How i can improve it?
    My website link http://www.todaymasters.com/ Please suggest me any tip?

    • Reply October 27, 2016 / 08:46 Ivan StefanovSiteGround Team

      You can improve your site speed following our tutorial available here.

      • Reply January 8, 2017 / 11:52 Abdul MajeedSiteGround Team

        please install WP Fastest Cache and see this result

  8. Reply December 20, 2016 / 05:41 VishalSiteGround Team

    Where would I add the code on my site? Is it the text box where I would paste the code? Thanks

    • Reply December 20, 2016 / 08:28 Ivan StefanovSiteGround Team

      Vishal, you should add this code in your websites .htaccess file. You can either edit it through File Manager or FTP.

      • Reply December 20, 2016 / 15:34 Vishal VashishtSiteGround Team

        Hi Ivan, thanks for your reply. Absolutely no idea as to how I can add this? You are my host, can I get this done through you guys? Thanks again

        • Reply December 21, 2016 / 08:32 Ivan StefanovSiteGround Team

          Vishal, we will be glad to help you with the leverage browser caching for your website - just submit a support ticket and my colleagues will address this concern as fast as possible.

  9. Reply January 12, 2017 / 16:44 RonSiteGround Team

    Is mod_expires enabled by default? ... apache server?

    • Reply January 17, 2017 / 12:13 escalationsSiteGround Team

      I would suggest checking this with your server administrator or hosting support team.

  10. Reply March 8, 2017 / 01:07 JohnSiteGround Team

    I removed a few lines of white space from my .htaccess files and it seems to be working now, I'm not 100% sure that was the problem as I did some other tweaking.

* (Required)