Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cache-control max-age meta tag not registering

I've put this in my head section. It appears in the page source in the browser.

<meta http-equiv="Cache-Control" content="max-age=1209600">

However, when I look in the Chrome extension Live HTTP Headers, it says the following.

Cache-Control: max-age=0
Content-Encoding: gzip
Content-Length: 5849
Content-Type: text/html; charset=utf-8
Date: Sat, 05 Apr 2014 04:29:16 GMT
Expires: Sat, 05 Apr 2014 04:29:16 GMT
Last-Modified: Sat, 05 Apr 2014 03:33:19 GMT

The max-age isn't registering. I've emptied the browser cache but it makes no difference.

Any explanations? This is the site, incidentally.

UPDATES:

Firebug similarly records Cache-Control: max-age=0.

Google also makes clear here that max-age overrides the Expires header (which I don't set) and that you don't need both.

like image 873
Nick Avatar asked Apr 05 '14 04:04

Nick


People also ask

What is a meta Cache Control tag?

The meta cache control tag allows Web publishers to define how pages should be handled by caches. They include directives to declare what should be cacheable, what may be stored by caches, modifications of the expiration mechanism, and re-validation and reload controls.

What is the max age of a cache response?

Cache-Control max-age. This directive tells the browser or intermediary cache how long the response can be used from the time it was requested. A max-age of 3600 means that the response can be used for the next 60 minutes before it needs to fetch a new response from the origin server.

What is the difference between no-cache and Max-age=0 and must-revalidate?

no-cache and max-age=0, must-revalidate indicates same meaning. Clients can cache a resource but must revalidate each time before using it. This means HTTP request occurs each time though, it can skip downloading HTTP body if the content is valid.

Is the in HTML5 meta tag still valid?

in HTML5? It is no longer valid according to the W3C Validator and the documentation. Show activity on this post. Putting caching instructions into meta tags is not a good idea, because although browsers may read them, proxies won't. For that reason, they are invalid and you should send caching instructions as real HTTP headers.


1 Answers

When you use tools like Live HTTP Headers, they show you the actual HTTP headers sent by the browser. What they do with meta tags used to simulate HTTP headers is a different issue. We can expect any conflict to be resolved in favor of the actual headers. (This has been normatively specified in HTML specs for Content-Type headers.)

To control cacheing, you should (at least primarily) use server configuration. See Caching Tutorial for Web Authors and Webmasters.

like image 145
Jukka K. Korpela Avatar answered Sep 20 '22 09:09

Jukka K. Korpela