"Bad value expires for attribute http-equiv on element meta"

RussellHarrower picture RussellHarrower · Jul 16, 2014 · Viewed 8.3k times · Source

Ok so I have been using the wrong code for I don't know how long now - it seems that

<meta http-equiv="expires" content="0">

is wrong and the following is correct

<meta http-equiv="expires" content="mon, 27 sep 2010 14:30:00 GMT">

So my question is how do I still get it to be 0 if they want me to put date format like above and how to I generate this without PHP/JavaScript? It seems stupid to put this in date format.

Answer

unor picture unor · Jul 16, 2014

You are not allowed to use the expires pragma directive in HTML5, as it is not defined in the HTML5 spec nor registered on the wiki page PragmaExtensions.

Instead, you should use the corresponding HTTP header.

According to RFC 4229, the Expires header field is defined in RFC 2616, and its definition is pretty clear about the format:

The format is an absolute date and time as defined by HTTP-date in section 3.3.1; it MUST be in RFC 1123 date format […]

Note that it also says about the 0 value:

HTTP/1.1 clients and caches MUST treat other invalid date formats, especially including the value "0", as in the past (i.e., "already expired").

About what you should do:

To mark a response as "already expired," an origin server sends an Expires date that is equal to the Date header value.