Site logo

Archived topic

Expire headers

4 replies · Started by Michel on February 16, 2022

Viewing posts 1–5 of 5

Hi everyone,

Totally stumped by something. I know it's not the responsibility of the GeneratePress theme but if anyone has some wisdom to offer, I'm keen to listen.

One thing that keeps popping out when doing a page speed test is the need to add expire headers. The catch: I have added that to the .htaccess file after checking a few tutorials.

I put in the following but Pingdom keeps saying that there are no expire headers. Any clue?

# BEGIN Expire headers
<IfModule mod_expires.c>
# Turn on the module.
ExpiresActive on
# Set the default expiry times.
ExpiresDefault "access plus 2 days"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/svg+xml "access 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/ico "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType text/html "access plus 600 seconds"
</IfModule>
# END Expire headers

Hi there,

could be Pingdom testing a cached page. Do other testing sites report the same issue?

You are correct. It's a cached page since a caching plugin is active. Perhaps I should ignore that warning as long as performance is good 🙂

You're welcome

Also make sure you have mod_expires (expires module) active on your server. Your code requires that module.

To verify your expiration settings in the .htaccess file are working correctly, you can examine the raw HTTP headers sent between the browser and web server. (To do this, use a browser plugin that displays the raw headers such as Live HTTP headers for Mozilla Firefox, or the Developer Tools feature in Google Chrome.) When content is marked for expiration, Apache adds the following lines to the HTTP response header (the exact values will vary based on your own .htaccess settings):

Cache-Control: max-age=86400
Expires: Thu, 02 Oct 2014 19:02:30 GMT

This archived topic is closed to new replies.