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.

Files: 
CommentFileSizeAuthor
#7 mod_expires-D6-1.patch1.27 KBc960657
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch mod_expires-D6-1_0.patch.
[ View ]
#4 mod_expires-2.patch1.3 KBc960657
Passed: 12056 passes, 0 fails, 0 exceptions
[ View ]
mod_expires-1.patch941 bytesc960657
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch mod_expires-1.patch.
[ View ]

Comments

Status:Needs review» Reviewed & tested by the community

Yep. We definitely want that.

By 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.

Status:Reviewed & tested by the community» Needs work

I 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.

Status:Needs work» Reviewed & tested by the community
StatusFileSize
new1.3 KB
Passed: 12056 passes, 0 fails, 0 exceptions
[ View ]

New patch with more comments.

Status:Reviewed & tested by the community» Fixed

Committed to CVS HEAD. Thanks!

Version:7.x-dev» 6.x-dev
Category:feature» bug
Status:Fixed» Patch (to be ported)

For 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.

Status:Patch (to be ported)» Needs review
StatusFileSize
new1.27 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch mod_expires-D6-1_0.patch.
[ View ]

Here 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.

Status:Needs review» Reviewed & tested by the community

We really want that. This helps in some server configurations.

Tested and +1 for 6.x

I get error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

fender, are you talking about D6 or D7? Which Apache version are you using? Is anything interesting written to Apache's error log?

i have drupal 6, is drupal 7 ready yet? :)

here is the bluehost apache specs

apache 1.3.37

@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?

Status:Reviewed & tested by the community» Fixed

Committed to Drupal 6, thanks!

Issue tags:+litespeed, +webserver

Has anyone tested this new .htacess with LiteSpeed webserver?

The 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?

Status:Fixed» Needs review

Re-test of mod_expires-1.patch from comment @comment was requested by Shellingfox.

I'm using shared web hosting and I have

AddHandler phpini-cgi .php .htm
Action phpini-cgi /cgi-bin/php5-custom-ini.cgi

in my .htaccess for setting php variables.

And due to this mod_expires settings don't work.
Please help.
Thank you.

@vnb
Change this

<FilesMatch \.php$>

to this
<FilesMatch (\.php|\.htm)$>

@mikeytown2
Thank you for suggestion. Although that doesn't work, the solution was close :

<FilesMatch "\.(php|cgi)$">

hooray!

subscribing

Status:Needs review» Fixed

Setting this back to fixed since it was already committed (#14).

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.