Forcing caching with Apache2 – mod_expires and mod_headers
Problem: Even when you use mod_expires to cache content on your server, some redirects may break the cache headers so the mod_expires will not output the right headers. This especially seems to happen when you have CMSs like Joomla/Drupal with SEO features and are trying to cache them.
This is how the mod_expires was set up before
<IfModule mod_expires.c> ExpiresDefault "access plus 20 minutes" ExpiresActive On </IfModule>
But these lines using mod_headers need to be added to remove the no-cache directives being output by the CMS:
Header unset Cache-Control: Header unset Expires: Header unset Pragma: Header unset Keep-Alive: Header unset Connection:
That removed the HTTP cache headers output by the CMS that seemed to be caused by the redirects (and which mod_expires was not replacing.)
You may need to enable mod_headers; it wasn’t enabled on my installation of Apache 2.2. The command to do that is:
a2enmod headers
1 comment so far
Leave a reply
Thanks a lot!
Solved my problem.