Page MenuHomePhabricator

Invalid "Expires" header value: -1; Invalid "Last-Modified" header date format
Closed, ResolvedPublic

Description

Author: steve-mediawiki

Description:
MediaWiki is generating an invalid Expires header. By rfc2616 the Expires
header value should be a date, not a number. Also, by rfc2616, the presence of
a "max-age" directive in the Cache-Control header overrides any Expires header,
regardless of which is more restrictive; so the invalid Expires header doesn't
have any effect on an HTTP 1.1-compliant cache or user agent. (Maybe it's there
trying to cover for caches that don't grok HTTP 1.1 right, but it's still
invalid to put a number there instead of a date.)

The fix is easy: remove the two 'header("Expires: -1")' lines in OutputPage.php.
I haven't tested with all UAs and caches, so if you know this was working
around a problem with a particular UA I'd suggest taking rfc2616's suggestion
about "pre-expiring" a page by naming a date known to be in the past -- that is,
change "Expires: -1" to "Expires: Wed, 31 Dec 2003 00:00:00 GMT".

Loving working with MediaWiki -- thank you!


Version: 1.3.x
Severity: minor
URL: http://mbrt.renlabs.com/wiki/

Details

Reference
bz276

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 6:48 PM
bzimport set Reference to bz276.
bzimport added a subscriber: Unknown Object (MLST).

steve-mediawiki wrote:

Fix Last-Modified date formats, eliminate redundant and invalid Expires header

Should have noticed this also: Last-Modified header format needs a leading zero
on day numbers less than 10, which can be done by using 'd' instead of 'j' as
the format character in PHP's gmtime (this is discussed at
http://us4.php.net/gmdate). Attached patch does both changes (remove Expires,
correct Last-Modified).

Attached:

jeluf wrote:

The Expires:-header is for HTTP/1.0 browsers. RFC2616 requires this header to be
ignored, or,
if no Cache-Control: is present, to be treated as in the past.

Fixed Last-Modified: headers in GlobalFunctions.php, rev 1.147

  • Bug 1907 has been marked as a duplicate of this bug. ***

jnareb wrote:

Added information about Last-Modified header to summary, to find more easily
patch to this bug.