How to Add Expire Headers to Speed Up your WordPress Site

Optimize your WordPress Site for SEO and Reduce your Bounce Rates.

Let us take care of it for you, for free!

All new hosting and maintenance clients receive a free HOUR of support each month for theme or plugin fixes, site optimization or malware removal!

GET FREE WP FIX NOW! While there are many different things you can do in order to make your site faster I'm going to post a little snippet to add in your .htaccess file that will set your Expire Headers time.

The faster your site loads the better is for your SEO and for your Bounce Rates.

Expire Headers is letting your browser to cache your website content and request them only after the time specified in that rule expires.

If you want to set Expire Headers for all of your image,js and css file you have to open and edit your .htaccess file and the following rule:

<FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css|woff)

quot;> ExpiresActive On ExpiresDefault A2592000 </FilesMatch>

FilesMatch sets the file extensions that are affected by the ExpiresActive rule while the ExpiresDefault sets the cache time, when that time expires then your website visitor browser will request once more the files.

ExpiresDefault is access time (A) plus 30 days (2592000 seconds), so using the same rule you can set your own ExpiresDefault time(just be careful to calculate in seconds).

If you want to set a separate Expire Headers rule for each of your filetypes then you can use the following snippet on your .htaccess.

ExpiresByType image/png A2592000
ExpiresByType image/gif A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType text/javascript A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType text/css A2592000

Let us take care of it for you, for free!

All new hosting and maintenance clients receive a free HOUR of support each month for theme or plugin fixes, site optimization or malware removal!


Comments (40)

  1. jasa web sekolah Reply

    June 16, 2014 at 8:02 am

    Thanks for your sharing.
    Now, my web more fast

  2. Bryan Reply

    August 12, 2014 at 10:04 am

    I tried in my site and not working.

    1. Fix My WP Reply

      September 5, 2014 at 1:17 am

      Did you get any error? How did you test for not working?

  3. Ankit Saxena Reply

    September 23, 2014 at 1:36 pm

    Well Its working like a charm. Thank You so bro 🙂

  4. Satish Kumar Ithamsetty Reply

    November 28, 2014 at 12:17 pm


    I am using WP super cache plugin. can i use this tip along with the plugin. Just i tried. .htaccess is not supporting (means Site showing 500 internal error). Thank you.

    Satish Kumar Ithamsetty

    1. Fix My WP Reply

      November 28, 2014 at 6:09 pm

      Hi Satish Kumar.
      500 error means your server is not compatible with .htaccess or some of the .htaccess directives are wrong.
      I suggest you first try it with WP Super Cache disabled and add directives one by one, if you are still having issues then stick just with the WP Super Cache which either way should be more than enough.

  5. Usman Reply

    December 10, 2014 at 10:29 am

    I’ve used far future expiry plugin for add expires in header but gtmetrix Yslow still showing that “Add expires in header”. Let me know what I can do for it.

    1. Fix My WP Reply

      December 10, 2014 at 9:58 pm

      Usman I suggest you do some research on the logs of GTMetrix.

  6. Tanveer Nawaz Reply

    February 4, 2015 at 6:14 pm

    Well Its working, my Web Speed 89%
    Thank You

  7. Saba Pervaiz Reply

    February 4, 2015 at 6:18 pm

    This information is very useful, my website is responding very well.

  8. Riad Ahmed Reply

    July 7, 2015 at 8:52 pm

    Thank you Very much . I used your code and Now google PageSpeed Insights increased from 56 to 67 ( mobile ) and in dexto 70 to 86 . Now my website is responding very fast. 😀

  9. Samuel Reply

    September 3, 2015 at 9:29 pm

    Htaccess is not working on Nginx. Apache only.

  10. Paul Reply

    June 2, 2016 at 6:36 pm

    Thanks for this!

    Works like a charm on my site. I use WP Super Cache and there’s no conflict.

    My site is hosted on a shared server @ Hostgator, and this will help BIG TIME to decrease server requests!

    Anyone whose site is on as shared server should use this snippet.

    Just goes to show what you can find on the internet — I stumbled upon this page by accident. Lol!

  11. Tushar Sharma Reply

    June 3, 2016 at 9:06 pm

    Hello, I’m already using these rules, and they work for all js files served from my server, except for


    How can I make these cacheable as well.

  12. Steven Reply

    June 15, 2016 at 9:25 pm

    Did no work on my VPS server. No errors or anything, just no change. 🙁

    1. Fix My WP Reply

      June 27, 2016 at 8:57 pm

      Hi Steven. Which is your site and hosting provider?

  13. raja Reply

    June 16, 2016 at 4:57 pm

    can any body help me to reduce my site speed

    1. Fix My WP Reply

      June 27, 2016 at 8:58 pm

      Hi Raja.
      Did you try following the “Add Expire Headers” tutorial?

  14. Sean Reply

    August 26, 2016 at 7:36 pm

    Hello I tried doing this for my blog but, its still the same. Please what can I do?

    1. Fix My WP Reply

      August 30, 2016 at 3:38 pm

      If you are serving content from sites other than your own then you can’t control their expire headers, same goes with compression.

    1. Fix My WP Reply

      September 14, 2016 at 9:24 pm

      You can only set the expire headers for content you host.

  15. stefie Reply

    September 26, 2016 at 4:35 pm

    Thank you!! It worked for me too!

    1. Neha Sharma Reply

      October 20, 2016 at 12:13 pm

      Can you help me ho can i Speed up my site ? Loading time is more than 5 seconds 🙁

      1. Fix My WP Reply

        November 7, 2016 at 10:09 pm

        Hello Neha.
        Did you follow the guideline found in this post?

  16. Rachit Reply

    September 30, 2016 at 9:27 am


    Thank you for the tip:

    But my GTMetrix still shows this:

    For Browser Caching. Kindly recommend.

    1. Fix My WP Reply

      September 30, 2016 at 10:36 am

      Hello Rachit.
      a href=””>Based on this report your browser caching fails for scripts that are not served within your own site, for example, &

      Since you don’t have direct access to those scripts and files its not possible for you to set their max-age or expires. The only solution would be to download them to your hosting account and load them locally. Of course this will create other issues related to the scripts be in sync with their source.
      I suggest to apply this solution only for Google Fonts; download them locally, edit your theme and change the include url and finally add the expire rules in your .htaccess. If you don’t know how to do this you can wait for my upcoming article which will be a short guide on how to speedup your site’s Google Fonts usage.

  17. mohammed jasim p Reply

    November 25, 2016 at 2:21 pm

    put this into ur .htacces file

    ExpiresActive on

    ExpiresByType image/jpg “access plus 10 year”
    ExpiresByType image/jpeg “access plus 10 year”
    ExpiresByType image/gif “access plus 10 year”
    ExpiresByType image/png “access plus 10 year”

  18. moumita Reply

    March 7, 2017 at 12:42 pm

    file type expires which I am using:

    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 text/html “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 7 days”

  19. gelombang otak Reply

    March 15, 2017 at 10:56 am

    I tried to my site and it’s work as well. Many thanks

  20. Sandeep Reply

    March 21, 2017 at 12:17 pm

    Awesome! Thanks for it. Really, Your work is appreciable and it worked for my site

  21. Bryan Reply

    April 11, 2017 at 8:04 pm

    Thanks for this article! It is exactly what I needed to boost my Pagespeed and Pingdom results. I now have a 100 performance grade on pingdom and 95/100 on google pagespeed.

  22. Europe Tours Reply

    April 21, 2017 at 8:42 am

    This information is very useful, my website is responding very well.

  23. Miriam Reply

    July 14, 2017 at 9:58 pm

    Thank you very much, you helped me a lot. Works perfect and boots my website 🙂

  24. Sreehari Sree Reply

    August 20, 2017 at 8:34 pm

    Thanks for sharing.
    I was looking for it 🙂

  25. Gursewak Singh Reply

    August 25, 2017 at 11:37 am

    Thank you, This information is very useful For me. Your work is appreciable and it worked for my site

  26. Sandy Rowley Reply

    September 28, 2017 at 10:49 pm

    This did the trick. Super fast and easy, just the way I like it. TY for the great posts on SEO audits.

Leave a Reply

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