The caching parameters of Drupal-generated HTML pages are set in two places:
A.) In the default ".htaccess" file in the default Drupal installation.
There's the following directive which should insure that any page with a "text/html" MIME-type is not cached by the browsers:
# Reduce the time dynamically generated pages are cache-able.
<IfModule mod_expires.c>
ExpiresByType text/html A1
</IfModule>
However this has two flaws:
1.a) This can work if and only if the mod_expires module is loaded ...
1.b) ... and it is loaded after mod_php* is loaded.
Since if mod_Expires is loaded first, then during the processing of the HTTP-request by mod_Expires the MIME-type of the page is not yet known. Or at least I suspect that this is the reason for the missing of the "Expires" header since I had no opportunity to switch the module load-order to check this.
2.) There should be an "ExpiresActive On" before the "ExpiresByType" directive, since in most Apache installations this is not set on a server and/or virtualhost level.
B.) The caching parameters are also set in the drupal_page_header() function, but not in every case. They are only set if "Page cache" is enabled in administration. Otherwise no caching/related HTTP headers are set.
Due to these issues Drupal-generated pages are automatically cached by the browser:
a.) if mod_expires is not enabled on the webserver or mod_expires is loaded before mod_php*
b.) and if "Page cache" is disabled in the administration menu.
One could argue whether this is a bug or not.
The missing "ExpiresActive On" directive is definitely a bug, since it is nowhere written in Drupal docs that one should have this directive set anywhere else in the Apache config.
The other problem (that caching-related HTTP headers are only set in drupal_page_header() if "Page cache" is enabled) might be considered a bug, too. It does make life harder for me since I cannot rely on mod_expires fixing the Expires header for me. I'd rather have Drupal generate the caching-related HTTP headers all the time (and not just with "Page cache" enabled) to prevent browsers from caching the generated pages.
Comments
Comment #1
Wesley Tanaka commentedsee also http://drupal.org/node/40597
Comment #2
Uwe Hermann commentedComment #3
magico commentedContinue discussion here http://drupal.org/node/38213