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!
GET FREE WP FIX NOW!
jasa web sekolah
June 16, 2014 at 8:02 am
Thanks for your sharing.
Now, my web more fast
Bryan
August 12, 2014 at 10:04 am
I tried in my site and not working.
Fix My WP
September 5, 2014 at 1:17 am
Did you get any error? How did you test for not working?
Ankit Saxena
September 23, 2014 at 1:36 pm
Well Its working like a charm. Thank You so bro 🙂
Satish Kumar Ithamsetty
November 28, 2014 at 12:17 pm
Hello,
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.
Regards
Satish Kumar Ithamsetty
http://www.BloggingDen.com
Fix My WP
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.
Usman
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.
Fix My WP
December 10, 2014 at 9:58 pm
Usman I suggest you do some research on the logs of GTMetrix.
Tanveer Nawaz
February 4, 2015 at 6:14 pm
Well Its working, my Web Speed 89%
Thank You
Saba Pervaiz
February 4, 2015 at 6:18 pm
This information is very useful, my website is responding very well.
Riad Ahmed
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. 😀
Samuel
September 3, 2015 at 9:29 pm
Htaccess is not working on Nginx. Apache only.
naseem
November 8, 2015 at 9:25 pm
nice its woking
Paul
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!
Tushar Sharma
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
/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.0
/wp-includes/js/jquery/jquery.js?ver=1.12.3
How can I make these cacheable as well.
Steven
June 15, 2016 at 9:25 pm
Did no work on my VPS server. No errors or anything, just no change. 🙁
Fix My WP
June 27, 2016 at 8:57 pm
Hi Steven. Which is your site and hosting provider?
raja
June 16, 2016 at 4:57 pm
can any body help me to reduce my site speed http://www.bollyera.com/
Fix My WP
June 27, 2016 at 8:58 pm
Hi Raja.
Did you try following the “Add Expire Headers” tutorial?
Sean
August 26, 2016 at 7:36 pm
Hello I tried doing this for my blog http://planetnob.com/ but, its still the same. Please what can I do?
Fix My WP
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.
prakash
September 8, 2016 at 3:09 pm
hi i want Add Expires headers for different domain ? how i can ? like gtmetrix shows :
http://fonts.googleapis.com/css?family=Montserrat%3A400%2C500%2C700
http://fonts.googleapis.com/css?family=Open+Sans%3A400%2C300
https://connect.facebook.net/en_US/all.js#xfbml=1&appId=712681982206086
http://platform.linkedin.com/in.js
http://fonts.googleapis.com/css?family=Montserrat:400,700
https://www.facebook.com/impression.php/f3a500994f8c7e/?api_key=712681982206086&lid=115&payload=%7B%22source%22%3A%22jssdk%22%7D
http://platform.twitter.com/widgets.js
https://apis.google.com/js/plusone.js
https://platform.linkedin.com/js/secureAnonymousFramework?v=0.0.1199-RC8.58145-1429&
https://connect.facebook.net/en_GB/all.js#xfbml=1&appId=54854384568
Fix My WP
September 14, 2016 at 9:24 pm
You can only set the expire headers for content you host.
prakash
September 16, 2016 at 10:09 am
ok thanks
stefie
September 26, 2016 at 4:35 pm
Thank you!! It worked for me too!
Stefie
Fix My WP
September 26, 2016 at 11:23 pm
Thank you!
Neha Sharma
October 20, 2016 at 12:13 pm
Can you help me ho can i Speed up my site ? http://hitorflop.net/ Loading time is more than 5 seconds 🙁
Fix My WP
November 7, 2016 at 10:09 pm
Hello Neha.
Did you follow the guideline found in this post?
Rachit
September 30, 2016 at 9:27 am
Hello
Thank you for the tip:
But my GTMetrix still shows this: https://gtmetrix.com/reports/motoroctane.com/0Co5Icsr
For Browser Caching. Kindly recommend.
Fix My WP
September 30, 2016 at 10:36 am
Hello Rachit.
a href=”https://www.webpagetest.org/result/160930_H4_4848507d058cfbcd3a70c29a33c93648/1/performance_optimization/#cache_static_content”>Based on this report your browser caching fails for scripts that are not served within your own site, for example 2mdn.net, zedo.com & fonts.googleapis.com.
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.
mohammed jasim p
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”
http://technaureus.com
moumita
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”
gelombang otak
March 15, 2017 at 10:56 am
I tried to my http://brainwave.co.id site and it’s work as well. Many thanks
Sandeep
March 21, 2017 at 12:17 pm
Awesome! Thanks for it. Really, Your work is appreciable and it worked for my site https://techflout.com
Bryan
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.
Europe Tours
April 21, 2017 at 8:42 am
This information is very useful, my website is responding very well.
Miriam
July 14, 2017 at 9:58 pm
Thank you very much, you helped me a lot. Works perfect and boots my website 🙂
Sreehari Sree
August 20, 2017 at 8:34 pm
Thanks for sharing.
I was looking for it 🙂
Gursewak Singh
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 https://antiexsolutions.com.
Sandy Rowley
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.