I have had the problem in all versions of apache 2 that the following does not work as expected:
ExpiresActive On ExpiresByType text/html A120
A request for http://host.domain.com/index.html has the correct Expires header added, but a request for http://host.domain.com/ does not.
I determined that mod_expires always ran before mod_dir, so mod_expires never matched the content-type. My solution was to change the following in mod_expires.c:
- ap_hook_fixups(add_expires,NULL,NULL,APR_HOOK_MIDDLE); + ap_hook_fixups(add_expires,NULL,NULL,APR_HOOK_REALLY_LAST);
This fixes my particular issue and does not seem to break anything else. Can others confirm this?
This patch is an improvement, but the problem goes further. Try setting a non-default ContentType in a CGI. ExpiresByType won't work as you might expect. Why not? The CGI creates the ContentType header during the handler phase, after all the fixups.
I've had this reported as a loss of function between 1.3 and 2.0, but I don't think it really is. In 1.3, the default ContentType seems to take effect earlier. So if your ExpiresByType happens to match the default, it appears to work in 1.3.
The good news for 2.x: mod_expires' fixup routine could be split in two, with the code that looks at the type running as a one-shot output filter, after the header filter. I don't know of a clean way to fix it in 1.3.
Greg