Currently, .htaccess disables ExpiresActive for index.php. This should really apply to all .php files. The mod_expires stuff is intended for static files. PHP scripts should set their caching headers explicitly.
The current behaviour is a problem e.g. in this situation:
If you access update.php while your database is unavailable, you will get a WSOD, and the response will contain the header Cache-Control: max-age=1209600
. Now, if you were accessing the server through e.g. an office proxy server, the proxy would cache that page, and you have to hit CTRL+F5 to force the proxy to fetch the page again (some proxies don't allow this).
This patch is inspired by Davy Van Den Bremt's suggested fix for #319420: Page cache makes browser cache pages for 2 weeks.
Comment | File | Size | Author |
---|---|---|---|
#7 | mod_expires-D6-1.patch | 1.27 KB | c960657 |
#4 | mod_expires-2.patch | 1.3 KB | c960657 |
mod_expires-1.patch | 941 bytes | c960657 | |
Comments
Comment #1
Damien Tournoud CreditAttribution: Damien Tournoud commentedYep. We definitely want that.
Comment #2
Damien Tournoud CreditAttribution: Damien Tournoud commentedBy the way, this allows us to solve a bug in Drupal 6 where, in some configuration, mod_expires sets the expired header even for PHP generated content (see #319420: Page cache makes browser cache pages for 2 weeks).
If this goes in to Drupal 7, I'll requalify this as a bug and ask to backport to Drupal 6.
Comment #3
Dries CreditAttribution: Dries commentedI think this should be committed. For bonus, points, please extend the code comment explaining _why_ this should be disabled. That will make it more future proof. Let's do a quick re-roll with an extended comment, and mark it RTBC. As always, good job c960657.
Comment #4
c960657 CreditAttribution: c960657 commentedNew patch with more comments.
Comment #5
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks!
Comment #6
Damien Tournoud CreditAttribution: Damien Tournoud commentedFor Drupal 6, this is a bug report. On some configurations, the text/html check doesn't work, because mod_expires is executed before mod_php.
Comment #7
c960657 CreditAttribution: c960657 commentedHere is a backport.
Note that it may have some impact on users who have put non-Drupal PHP files in a subdirectory. PHP scripts that output text/html will no longer have the “cache no longer than 1 second” restriction - the cache period is now decided by the browser. If a PHP script is used to output non-text/html data, e.g. images, these will no longer be cached for two weeks. But I guess this isn't too big an issue. In general, if a PHP script does not set cache headers itself, it cannot make to hard assumptions about how it will be cached in browsers and proxies.
Comment #8
Damien Tournoud CreditAttribution: Damien Tournoud commentedWe really want that. This helps in some server configurations.
Comment #9
mikeytown2 CreditAttribution: mikeytown2 commentedTested and +1 for 6.x
Comment #10
fender-dupe CreditAttribution: fender-dupe commentedI get error
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Comment #11
c960657 CreditAttribution: c960657 commentedfender, are you talking about D6 or D7? Which Apache version are you using? Is anything interesting written to Apache's error log?
Comment #12
fender-dupe CreditAttribution: fender-dupe commentedi have drupal 6, is drupal 7 ready yet? :)
here is the bluehost apache specs
apache 1.3.37
Comment #13
mikeytown2 CreditAttribution: mikeytown2 commented@fender
My guess is you patched the htaccess file by hand incorrectly. Can you double check & if your still encountering that error can you attach your htacces file?
Comment #14
Gábor HojtsyCommitted to Drupal 6, thanks!
Comment #15
gunwitch CreditAttribution: gunwitch commentedHas anyone tested this new .htacess with LiteSpeed webserver?
Comment #16
df412 CreditAttribution: df412 commentedThe new .htacess is not working on Mediatemple's Gridserver. I don't know whether this is a Mediatemple's bug or a Drupal 15 bug.
I am using the old .htacess file (Drupal 14 version) and my Drupal 15 site works properly with that.
Is there anything wrong with that?
Comment #19
vnb CreditAttribution: vnb commentedI'm using shared web hosting and I have
in my .htaccess for setting php variables.
And due to this mod_expires settings don't work.
Please help.
Thank you.
Comment #20
mikeytown2 CreditAttribution: mikeytown2 commented@vnb
Change this
to this
Comment #21
vnb CreditAttribution: vnb commented@mikeytown2
Thank you for suggestion. Although that doesn't work, the solution was close :
<FilesMatch "\.(php|cgi)$">
hooray!
Comment #22
izmeez CreditAttribution: izmeez commentedsubscribing
Comment #23
mikeytown2 CreditAttribution: mikeytown2 commentedSetting this back to fixed since it was already committed (#14).