Soliloquy - The Best Responsive WordPress Slider Plugin

How to Leverage Browser Caching in WordPress via .htaccess

Share This Post

We should always be looking for ways to improve the functionality of our blogs. One of the easiest ways to improve our blog functionality and speed is to leverage browser caching.

Another way of saying this is that we add expires or cache control headers for our blog. In Layman’s terms, by leveraging browser caching, we can reduce the number of HTTP requests that the server needs to process, thus reducing loading times and improving user experience and website performance. And as an added bonus, when we leverage browser caching, we improve our scores on PageSpeed and YSlow!.

In order to do this, we will need to modify our .htaccess file and add in the appropriate directives.

Finding and Modifying .htaccess

For those that are not tech savvy, modifying the .htaccess file might seem a little daunting. In reality, it is quite simple. For this tutorial, if you can cut and paste correctly, you should be worry-free.

You can access your .htaccess file through cPanel by clicking on the File Manager. When the popup box appears, click on the Web Root option and make sure that the “Show hidden files” option is checked.

Pasting in the Directives to Leverage Browser Caching

Open up your .htaccess file and paste in the following directives at the top of the file:

By using this code, our main static files (images, CSS, PDF’s, JS, etc.) will be cached in order to produce faster loading times in the future.

Now save your .htaccess file and view your site through the eyes of PageSpeed and YSlow! – you are now leveraging browser caching for your site!

It is easy to leverage browser caching in WordPress with this tutorial – enjoy!

Have you enjoyed reading How to Leverage Browser Caching in WordPress via .htaccess? Sign up below to get regular content updates and also get my "7 Tips to a Professional WordPress Setup" absolutely free!

About Thomas Griffin

I live and breathe WordPress. I create products around WordPress (Soliloquy and OptinMonster), contribute to WordPress core and do lots of fun development around WordPress in general. You can find me on Twitter, Facebook and Google+.

149 Responses to “How to Leverage Browser Caching in WordPress via .htaccess”

  1. Paul says:

    Hi Thomas
    Very interesting. i knew nothing about this.
    Can you give a brief explanation of what PageSpeed and Yslow are.

    • Sure, no problem. :)

      PageSpeed and YSlow! are both add-ons to Firefox and Chrome that allow you to test the performance of your website. Of the many things that they analyze, one of them is to see if you leverage browser caching. Each of these development tools are used to help you optimize your site for the best possible performance across web browsers and internet connections.

      Hope this is helpful for you!

  2. Andreas says:

    Great tip!

    Exactly what I was looking for. Missed that part in my optimizing process, so thanks!
    However, for some reason the javascript files wasn´t included (they showed default value) so I changed the default to 1 month. Quick and dirty fix, but it works..


  3. David says:

    I looked in htaccess and found some code from W3 Total Cache – a plugin I removed a while ago. So I chopped it out and put in your code and wondered all the while at my recklessness, even as I did it.

    All seems to be OK.

    Thanks :-)

  4. Jonathan says:

    Thanks for the tip. I’m looking for everything that I can use to cache our site.

  5. [...] image/x-icon "access 1 year" ExpiresDefault "access 2 days" ## EXPIRES CACHING ## Source:… Related PostsNo related posts. Leave a Reply Click here to cancel [...]

  6. [...] image/x-icon "access 1 year" ExpiresDefault "access 2 days" ## EXPIRES CACHING ## Fonte: Tags: Tips and tricks, WordPress Enjoyed this Post?Subscribe to our RSS Feed, Follow us on [...]

  7. pc-manden says:

    I ended up with an 500 Server Side Error ?

  8. pc-manden says:

    By wrapping it up in an IF-statement, you won’t get a 500 error if it’s not supported. If the expires module isn’t active, it won’t help you, but at least you don’t get any errors by using it.

    Like this:

    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”


    • Thanks for pointing that out! I will update the post to include the conditional statement. I guess I just figured most servers would have mod_expires, but I suppose some shared servers still neglect to allow that directive to customers.

  9. pc-manden says:

    Sorry, won’t show the ‘wrapping’ codes in comments:

    (IfModule mod_expires.c)
    - expires statements –

    and swap the ( and ) with

  10. pc-manden says:

    LOL cant write those arrows! :-)
    You have to use arrows around the IFs…

  11. Vincent says:

    So do we or do we not include th if statement?
    (IfModule mod_expires.c)

    • Vincent,

      Yes, you should include the statements in order to keep from returning 500 server errors in case you don’t have the module activated. I actually had it in the original post, but I forgot to escape the HTML, which removed that statement!


  12. [...] for Windows IIS server.Below are few references:.htaccess Rules for Website Speed OptimizationHow to Leverage Browser Caching in WordPress via .htaccessSpeed up Website by Compressing and Caching your content with .htaccessConfigure IIS 7 Output [...]

  13. Sagive SEO says:

    Thanks a lot man! finally something easy to read and easy to follow.. i went from 82 to 84 in my page speed :)

    Cheers, Sagive

  14. roland says:

    Should your pagespeed and the announcement in Google Pages Speed improve directly? After adding this script to the .htaccess nothing changes for my website.

    • luis says:

      did you get this figured out? , I am having the same issue

      • Jamie says:

        Me 3, my overall score did not increase from 61 to 61, in my leverage browser caching whet from 27 to 38, but overall score did not improve, any help or recommendations for (very image heavy site)

  15. Cool – I was struggling to get my Page Speed sorted and by removing the W3 Total Cache code from my .htaccess and adding yours I went from 76% to 83%. All my sites will use this from now on.



  16. Jc says:

    I have set this code for css. i surf my website it is running fine. then i changed something in css, but changes are coming in the website although i cached it. it means no cache done. can you please explain why i am not getting cached css contents?

  17. rdd says:

    Please somebody tell me that How can I get the cache type(1min cache,5min cache,….) of the whole page or of a part in a website??

  18. Hmm.. I will check this now.. if works.. You are simple genius,., If not it means I dont even know to copy paste correctly ;)

  19. anupal says:

    well done !! nice thanxx

  20. luis says:

    Hello, I placed this code in both the .htaccess file on thehome folder and the .htaccess file in wp-content/cache… I am still getting a recomendation on Yslow and Pagespeed to leverega browser chache, any idea why, and how can I check if it is working?
    Thanks so much

    • Kev says:

      Same here! It’s very frustrating. I have setup W3 Total Cache which is great (warning to those using themes with ajax drop down menus though) but for some reason the browser caching isn’t working according to GTMetrix and Google Page Speed.

      I tried placing this code in the .htaccess file but no changes.
      I tried replacing the W3 browser cache info with this code in htaccess – no change

      Do I need to disable W3 Total Cache in order for this to work – seems kinda counter productive since it works very well with most other things. I really would like someone to help – is this something from the ISP perhaps?

  21. phill says:

    Thanks Thomas, this worked a treat. Finaly got my Google page speed score above 90 :)

  22. velos says:

    very nice and thank you ……
    It has helped improve my pagespeed Site

  23. Shibby says:

    Very usefull code, but does the W3TC Caching plugin does his or should i add it?

  24. James says:

    Anyone able to rewite this in zeus?

  25. Prüfung says:

    This is exactly what i was looking for. Thanks for sharing. I have one question about it though. I understand that whenever i reload the page it will show the cached files. But will it work to reload the files from the server again by pressing CTRL + F5?

  26. Thanks for showing how this is done. I’ve just added this code across all my sites and not had any problems, however I did find it quite esasperating while testing using the Page Speed Tools because the results were telling me that browser caching was not being leveraged in some cases even when it clearly was. I had the same issue with Gzip compression which has been enabled across all my sites.

    After roughly an hour of confusion while trying to understand this in FireFox Page Tools I tried Google’s own and found it was giving different results. Then I tried using the same extension for Chrome and found yet again it wasn’t the same, so in the end I had to conclude I had done as much as possible and leave it at that…

    • Prüfung says:

      hi ashley, i used to check loading times. its easy to understand and gives good advice to speed up your website. this might help… ;)

      • Thanks for that link Prüfung. I’ve been having a play with some of my sites to see how they perform there.

        My interest in this came about through some frustration at viewing my site performance stats inside the Google webmaster tools where it showed one of my domains was slower than 90% of the sites on the web. This grated my pride because I had gone all out for efficiency and the sites were hosted on a high end dedicated server, so it should have been screaming fast. Google was saying that one of my sites took an average of nearly 8 seconds to open but I could never understand how they were finding it so slow when it was opening almost instantly for me. I wondered if they are still on a 28K modem?

        Now I’ve made these changes I want to wait and see if my scores improve inside the webmaster tools. I probably shouldn’t worry about it but it was really bugging me and I wondered if it was affecting my search ranking.

  27. Sandeep says:

    After adding this code to .htaccess my page speed is decreased from 78/100 now it is 70/100 and still red icon showing expiry problem. I tested on both YSlow and Google Page speed. Please help

  28. sudha says:

    If you can leverage browser caching, you can increase website speed considerably. As Google starts considering site speed as a SEO parameter, webmasters can leverage browser caching to improve site speed and get better search engine rankings.

  29. I’ve just been looking at this again and it looks as though browser caching is working on my home page but not other pages. Anybody know why that might be?

  30. Rein says:

    Thank you so much for this; in Pingdom Tools Pagespeed my Leverage browser caching score went from 17 to 42 after using your code.

    There are however a lot of recources that still have a hort freshness lifetime, but I’m not sure why. The bulk of them are (cropped?) images, like these:


    Got about 20-25 of these.
    Any idea how I can improve those as well? :)
    Much appreciated!

    • Joseph says:

      Try WP It’s a image compression style plugin that helps reduce the amount of crap that images can carry. I’ve just had my host moan at me for using too much MySQL CPU Usage on the shared server so I’ve been doing some tips and tricks everywhere over the last few days so I recommend that as it does help a little.

      All just to save those few extra milliseconds! It’s almost laughable!

      I’m about to try this code and I hope it to work. I’ve got the WP Super Cache plugin and I’m including this code at the very top as you suggest

  31. Susan says:

    Thank you – I just implemented this on one of my sites and already noticed a change in speed.

  32. Joseph says:

    If I my ask, how long am I likely to have to wait to see a noticeable difference if any?

    • Joseph says:

      I noticed today that the speed score has improved but I am still getting a medium priority on Google Page Speed and it is stating that;

      “The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:”

      And it lists css, js and png’s that : (expiration not specified)

      So I’m unsure whether it is actually working or not.

  33. After adding this to .htaccess, my site page speed decreased from 91 to 86!!! Strange.. Google Page Speed test now suggesting me to leverage browser caching.. :-(

  34. Nadiar says:

    Nice work,.. i don’t thnking .httacess can do that

    let see the ressult…

  35. Tom says:

    Hey Thomas, not tried this form of browser caching before but now that I’m trying to increase the performance of my WordPress blog I’ll certainly give it a go. Can I ask though, how do you specify a single file?

  36. Izzy says:

    what happens if I edit a file, say the css or change a picture after adding the code to the .htaccess file? the browsers won’t show the edited files until the expire date? that can’t be right, what do I need to do when I change something?

  37. If you are using Joomla – edit htaccess

    Header unset ETag
    Header unset Last-Modified

    FileETag None

    Header unset Cache-control
    Header set Expires “access plus 1 month”

  38. For Joomla

    Header unset ETag
    Header unset Last-Modified

    FileETag None

    Header unset Cache-control
    Header set Expires “access plus 1 month”

  39. [...] handle all files so I recommend you add some code to your .htaccess file as described on this post: How to Leverage Browser Caching in WordPress via .htaccess. This got rid of those errors for [...]

  40. Phoenix says:

    Hi Thomas,
    Thanx for this trick,
    92 my page speed rank now
    thank you so much.

  41. This has been quite helpful – thanks for helping speed up my site!

  42. Richard says:

    Hey! Thanks for the tips.

    I have the following code in my “.htaccess” file:

    # To set your custom php.ini, add the following line to this file:
    # suphp_configpath /home/yourusername/path/to/php.ini

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    # END WordPress

    Should the code your recommending be in addition to this on a new line outside of the # END WordPress, or should the WordPress Code be removed completely? If someone could email me, that’d be great — thanks:

  43. Tams says:

    Thank you for posting this! It worked perfectly to eliminate the error I received in PageSpeed for Leveraging my Browser. I’m glad someone knew how to do this easily. Thanks again.

  44. [...] keywords: leverage browser caching source:… [...]

  45. Hi Thomas,
    Greatly thanks for your tricks. My page score improve tremendously after pasting the code into .htaccess of all my wordpress site.
    I should have found this earlier.

  46. Caroline says:

    Hi there,

    I am afraid I get a 500 Server Error when I paste your code into my .htaccess file.

    I have tried pasting it above and below the other code in the file, as well as only including your code in the file.

    This is the code already in my .htaccess file:

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /wordpress/
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /wordpress/index.php [L]

    # END WordPress

    Hope someone can help!

    • Caroline says:

      FYI I included your code just in your post. The if statements have been stripped out.

      • David Vildebrand says:

        If you strip out the if statements and then get a 500, it is very likely your webserver does not have the mod_expires module enabled. You’ll need shell/root access to do this. Research “apache enable modules” for additional information.

    • Michael says:

      To hit 2 flies in 1 attempt, i will suggest, hitting both mod_expire. mod_mime and mod_deflate:

      Options -Indexes

      RewriteEngine On
      RewriteBase /
      RewriteRule ^index.php$ – [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]


      # Enable expirations
      ExpiresActive On
      # Default directive
      ExpiresDefault “access plus 1 month”
      # My favicon
      ExpiresByType image/x-icon “access plus 1 year”
      # Images
      ExpiresByType image/gif “access plus 1 month”
      ExpiresByType image/png “access plus 1 month”
      ExpiresByType image/jpg “access plus 1 month”
      ExpiresByType image/jpeg “access plus 1 month”
      # CSS
      ExpiresByType text/css “access 1 month”
      # Javascript
      ExpiresByType application/javascript “access 1 month”

      AddType application/x-javascript .js
      AddType text/css .css

      SetOutputFilter DEFLATE

      SetEnvIfNoCase Request_URI .(?:rar|zip)$ no-gzip dont-vary
      SetEnvIfNoCase Request_URI .(?:gif|jpg|png)$ no-gzip dont-vary
      SetEnvIfNoCase Request_URI .(?:avi|mov|mp4)$ no-gzip dont-vary
      SetEnvIfNoCase Request_URI .mp3$ no-gzip dont-vary

      Header append Vary User-Agent env=!dont-vary

      # END WordPress

      # And i would also add a blocking of lipwww-perl:

      # Bloker lipwww-perl
      SetEnvIfNoCase User-Agent “^libwww-perl*” block_bad_bots
      Deny from env=block_bad_bots

  47. Ante says:

    I have added this code to my .htaccess file, and I noticed that my page is lot faster, but when I use is still says that I have to enable leverage browser caching. Any idea??

  48. salvatore says:

    Good hints, I would like to note that in some case Google PageSpeed Insights does NOT “see” changes immediately. You can also use W3 Total Cache plugin if you use WordPress as an alternative, and it works well.

  49. wirowiro says:

    Wow, That is very easy to do and the result is wonderful. Thank you very much.

  50. wpshouter says:

    finally it worked tnx a ton dude :) i was searching last few hours for this solution.

  51. It works well, I just added those .htaccess codes to my blog and it’s loading very fast.

  52. Free-Market Guy says:

    Thanks so much for your browser caching code for .htaccess

  53. [...] The next issue that it identified was a lack of browser caching so I updated my .htaccess file to ensure that files that could be cached by the browser would be as recommended in this post. [...]

  54. [...] Code Credit: [...]

  55. This is a very nice article on htaccess i like your article.

  56. Hi there – works fantastically well for me. Thanks so much. My site has improved a lot.

  57. Thank you! It took me a second to realize you can edit the .htaccess file after right clicking. That might help other readers. So glad for this easy code!

  58. Wonderful Mumbai says:

    How does one do this for a Windows server (IIS)?

    Thank you.

  59. hey i added the code to my htaccess. it has improved. but still there are some js and gif images for which it says to leverage browser cache. pls help.

  60. Thanks a lot Thomas, for such a nice and clear guide :)

  61. Thanks a lot for this information.

  62. […] Untested on shared hosting. View reference article. […]

  63. PS3 Repair Guide says:

    Great, thanks for your support, I got rid of the RED point, now is yellow, I noticed this at the bottom line:

    ExpiresDefault “access 2 days” : You get yellow Point instead of the Red point BUT:

    If you set it to 1 month you absolutely get rid of yellow/red exclamation points. I hope this helps somebody

    ALSO I have a question, since my site is an affiliate WordPress site, how or where can I set cookies or something so my affiliate links don´t die after two days, but over the whole year, which is the maximum time allowed by the RFC guidelines. (I really don´t have an idea of what is that anyway).

    But as an affiliate remember that the last link that takes the customer to the sale is the one that gets paid, and if your cookies or affiliate links die after 2 days or 1 month, so you hope to last till the end.
    I don´t really know if I´m being clear enough.

    Thanks for your support, great article and WATCH OUT on the other result on Google, I tried before right now another code and my website got down, i got the 500 error, I erase the code and it got up again, and paste the code on this website and got rid of the red points, change then the last line and set it for 1 month and got rid of the yellow point.
    Thanks and cheers.

  64. Nerd Glasses Fashion says:

    Thanks a ton!!! After trying hard to configure W3 Total Cache i just removed the plugin and inserted the code. Page Speed 92/100!

  65. Pinoy_MEME says:

    wow working fine on my blog. thanks bro for this big help…keep sharing..

  66. arunkallarackal says:

    Thanks a lot friend! Worked perfectly on my blog!

  67. Thanks Thomas for the tips! I have added the rules and tested, my speed got 95% from 93% Awesome! :)

  68. Hi Thomas, I am facing up with one issue here, there is one page where the google form was embedded and now after the code has been added i am getting this error message in place of the form “Unable to process Google Form. Server is responding with403 Permission Denied error.”

    It is happening because of the dynamic google form?

  69. Maxwell Purrington says:

    Now if only the author had only told those of us who are not tech savvy how to access the “cpanel.”

  70. Thank you very much for this Thomas, I am trying to follow up your instruction but it is rather confusing. You say I should open the .htaccess file in web root but from the hostgator they say me I should do it in .htaccess of the public_html of the domain Can you please help me to clarify this? Thank you so much!

  71. it doesnt do anything.. i have wp super cache.. is this a problem?

  72. Týr says:

    Why does my admin bar disappear on my front page after this mod? It is great mod improved my site performance score from 85 to 92/100 and 74% faster than all sites, this is a widgetized news site big front page running 30+ widgets. size 2.1MB

    I imagine being main page cached may have something to do with it. I can leave a window open of just go to a page other than home or a post and admin bar shows fine.

    Thanks for mod

    • griffinjt says:

      Yes – it is definitely because your browser has cached that page. Just clear out your browser cache and you should be good to go.

      • Týr says:

        So this means any new content published or media added needs auto refresh of page? Thanks for reply first I have seen of this method.

        • Týr says:

          Just noticed this messes with my WP Touch plugin which is a must have the on/off mode does not work properly have to hit on or off then do a manual refresh normal people can’t figure this out excellent caching though but will have to drop for this reason. Also enabled wptouch restricted which prevents anything from interfering and does the same the stuff if you know of a way to stop this please let me know but still excellent work here,

  73. gaurang says:

    i use this code….but my shopping cart is not working properly…

  74. Kim Butler says:

    Excellent article and instruction. This sped up every website I own and manage.

  75. ChicRenegade says:

    Thank you soooooo much!!!!

  76. […] This one is another common issue, that can be fixed by setting an expiry date or maximum age for static resources (like images) in the HTTP headers to allow better browser caching. That sounds pretty complicated, but all you have to do is copy and past the following code into your .htaccess file, and you’d done (credit Thomas Griffin): […]

  77. Thanks for this, this was very helpful! Didn’t realize it would be so easy!

  78. Diana says:

    I have WP super cache but this does not get rid of the (No max-age or expires) messages in webpagetest. I found your code that seems to be to solve ALL my problems but I worry if this is compatible with the WP super cache plugin? I am very afraid to break anything since I would not have a clue on fixing it. I spent 2 whole days trying to speed up my site but it is still very slow…
    Thanks for any help!

  79. @jthomasgriffin This is such an incredible post man!!!!!!!!!!!! Thanks.

    Should I still need W3 Total Cache or not, please suggest

  80. branduxd says:

    Thank you so much, i have added the code into my .htaccess file. it’s working fine now.
    And i need another help. if you can help me out it would be great, i am trying to enable gzip but i don’t know what are the steps to complete.

    • Michael says:

      This will hit both mod_expire, modmime and mod_deflate, this way you will get your comptession on gzip, (note, on apache server), the last 3 lines blocks for bad bots, you can delate that, if you dont know them ;-)

      RewriteEngine On
      RewriteBase /
      RewriteRule ^index.php$ – [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]


      # Enable expirations
      ExpiresActive On
      # Default directive
      ExpiresDefault “access plus 1 month”
      # My favicon
      ExpiresByType image/x-icon “access plus 1 year”
      # Images
      ExpiresByType image/gif “access plus 1 month”
      ExpiresByType image/png “access plus 1 month”
      ExpiresByType image/jpg “access plus 1 month”
      ExpiresByType image/jpeg “access plus 1 month”
      # CSS
      ExpiresByType text/css “access 1 month”
      # Javascript
      ExpiresByType application/javascript “access 1 month”

      AddType application/x-javascript .js
      AddType text/css .css

      SetOutputFilter DEFLATE

      SetEnvIfNoCase Request_URI .(?:rar|zip)$ no-gzip dont-vary
      SetEnvIfNoCase Request_URI .(?:gif|jpg|png)$ no-gzip dont-vary
      SetEnvIfNoCase Request_URI .(?:avi|mov|mp4)$ no-gzip dont-vary
      SetEnvIfNoCase Request_URI .mp3$ no-gzip dont-vary

      Header append Vary User-Agent env=!dont-vary

      # END WordPress

      # Bloker lipwww-perl
      SetEnvIfNoCase User-Agent “^libwww-perl*” block_bad_bots
      Deny from env=block_bad_bots

  81. opencodez says:

    Great technique. I am trying this on my site. Will update you on perfomance.

  82. Justin says:

    Hi Thomas,

    My ht access file looks like this:

    RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(.*)$$3

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    # END WordPress

    Should I place the cache code you gave above the redirectmatch?

  83. jay says:

    Wow thanks for your information- you the man!!!!!!

  84. jay says:

    im at 71/100 how can i improve the site?

  85. Jorge A. Gonzalez says:

    Thanks! Wondering why this isn’t done by WordPress out of the box.

  86. Great Work. So simple. Thanks a bunch. I use quick cache and was hesitant to modify the .htaccess since Quick Cache also offers some expiry fixes. So, I only entered the image expirations and that lifted my speed by 2%….

    Not much, I know, but, as my grandmother used to say… “Every Mickle makes a Muckle.” It all adds up. Thanks Thomas. If I could afford you, I would hire you!

  87. This was a really easy to use and understand post. Going to follow your site :)

  88. Andrej Mikula says:

    Google wants me to cache CSS as well. How can I do that please?

  89. wao amazing, i have tried at least half of dozen of plugins including w 3 total cache on my blog but everyone had its own hitch. can’t believe it was that simple. bravo man =D

  90. Maybe this is a silly question but if you set CSS to be one month, and you modify a CSS file, how do you force it to look at the newly updated CSS file?

    • Incidentally, I’m stoked you are the man behind OptinMonster because a lot of my site speed issues came from Popup domination and OptinSkin. The fact that you are blogging about page speed lets me know that you care about that and this is great for OptInMonster as I’m sure you will try and keep it nice and speedy :)

  91. SñIþêr Pal says:

    Hello Thomas
    CODE is already good but can you act like this code to blogger?

  92. […] from… […]

  93. […] from… […]

  94. Sam Crowe says:

    Where is the tutorial with the code? I’m not seeing it in the page above.

  95. Robert Conway says:

    Can I access my .htaccess file with my site?

  96. sirsha says:

    Thanks you very much. It was a very easy tutorial. I could implement in a few seconds and also see results.

  97. someshl says:

    This didn’t worked out for me.
    Please assist.

  98. It’s great… tested and found good

  99. Bret Painter says:

    Hi, I’ve see a couple of people ask this but no answer. I’m running WP Super Cache also and have paste the code in at the top of the .htaccess but PageSpeed Insights are still telling me to leverage browser caching? –

  100. Daniel Dibble says:

    Yeee Haa. Worked like a champ! Thank You!

  101. mndawood says:

    Hello, I am hosting my WordPress site on .Net environment, where web.config is used in place of .htaccess .. please advise on how can I modify this syntax to fit in a web.config?

  102. I did the same thing with two ways. One, you said via htaccess, and second using Wp-total cache. Is it Ok or I have to use only one tactic? Which one is better BTW!! I am applying both on my blog. Waiting for your kind response..!

  103. Worked like a charm on! The minute before I integrated the code in the .htaccess file, my “Browser Caching” score on pingdom was merely 20/100. Now it reached 70/100! Great improvement. One question: can this be improved even further (I’m thinking of something like 90/100) or are there limits?

    • Alright, quick edit since my message (one minute ago): my “Browser Caching” score on pingdom is now 88/100! I guess my server needed a bit of extra time to sort/tag all cachable items and serve them to the browser. Score is now really awesome. Thanks again!

  104. […] if you don’t know how to optimize images before uploading them to your website, install the EWWW Image Optimizer. When you upload images, make sure they are the correct dimensions (instead of resizing after the […]

  105. Really nice. That made PageSpeed Insights happier. Cheers!

  106. Mona Ali says:

    شركة نقل اثاث بالرياض

    شركة كشف تسربات المياه

    شركة عزل مائى بالرياض

    نقل عفش مكة

    شركة نقل عفش مكة

    شركة تنظيف بجدة

    شركات نقل عفش مكة

    شركة عزل خزانات بجدة

    شركات مكافحة حشرات بجدة

    عزل خزانات

    شركات العزل الحراري بالرياض

    عزل مائي في

    دكتور عماد
    جراح تصغير المعدة بالمنصورة

    بالون المعدة

    تدبيس المعدة

    شركة القمة
    لابادة الحشرات بالرياض

    شركة مكافحة
    البق بالرياض

    شركة مكافحة
    النمل الابيض بالرياض

    شركات نقل اثاث الرياض

    شركة كشف تسربات بالرياض

    نقل اثاث

    نقل اثاث بالمدينة

    شركة رش مبيدات بالمدينة المنورة

    مكافحة حشرات بالمدينة المنورة

    نقل اثاث بجدة

    كشف تسربات المياة بجدة

    شركة تنظيف خزانات بجدة

    تنظيف فلل بالدمام

    شركة تنظيف بالدمام

    شركة تنظيف شقق بالدمام

    نقل عفش بالرياض

    شركة كشف تسربات بالرياض

    تنظيف فلل بالرياض

    شركه عزل
    خزانات بالمدينه المنوره

    شركة تنظيف بالقطيف

    شركة تنظيف بيارات





  107. […] if you are not using a plugin and are comfortable using DIY step by step instructions.  Check out How to Leverage Browser Caching in WordPress via .htaccess. This method requires you to have access to your files via a admin panel or an ftp […]

  108. says:

    Ca-tching! This got rid of my “You should leverage browser caching” on! Thanks a bunch!

  109. MonitorPT says:

    Completely works for me! Thanks

  110. Marcel says:

    Does this work if I’m not using wordpress? If so why, mention wordpress so much if it works for all Apache servers?

  111. Thanks for this post. Even after these changes, the Leverage Browser Cache warning is active for the Javascript (.js) resources. Any ideas?

Leave a Reply