How to Add Expire Headers to Speed Up your WordPress Site
Last updated on April 25th, 2014 at 12:40 am
Optimize your WordPress Site for SEO and Reduce your Bounce Rates.
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)$"> 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.
Latest posts by Makis Mourelatos (see all)
- How Find Out If Your Website Is Hacked - June 23, 2017
- Extra Hardening: Take care your HTTP Security Headers - May 15, 2017
- WordPress Hacked Redirect, How to Detect and Clean it - January 2, 2017