Setting Expiry Date In the HTTP Headers for Static Resources In WordPress

If you run a page speed test for your WordPress blog and it’s recommended that you should setting an expiry date or a maximum age in the HTTP headers for static resources, you can add the code below into your .htaccess file below the " RewriteBase / " line

#set expire headers
<FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css|woff)$">
ExpiresActive On
ExpiresDefault A2592000
</FilesMatch>

After some minutes, you can run the test again and you should notice that resources with no expiry date prior to the htaccess modification now have expiry date.

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

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).

Source : How to Speed Up your WordPress by Adding Expire Headers by FixMyWP.com

2 Likes

Exactly what I was looking for. I have been wondering how to get that fixed. Thank you so much for this resource.

BTW have you used “GZIP”? @jidetheblogger Anything to say?

@RealityEmma see this >> This GZIP Test Tool Checks If Your Web Page Is Compressed

1 Like

How about for blogger?