Why does the Google homepage logo work with conflicting "Expires" and "Cache-Control" headers?

Here is the logo that is currently used on www.google.com:

http://www.google.com/images/logos/ps_logo2.png

Here is his HTTP response:

HTTP/1.1 200 OK Content-Type: image/png Last-Modified: Thu, 05 Aug 2010 22:54:44 GMT Date: Fri, 25 Mar 2011 16:41:05 GMT Expires: Fri, 25 Mar 2011 16:41:05 GMT Cache-Control: private, max-age=31536000 X-Content-Type-Options: nosniff Server: sffe Content-Length: 26209 Age: 0 Via: 1.1 localhost.localdomain 

The Cache-Control header says it's good for 1 year. But Expires is the same as Date , i.e. It is out of date immediately.

Why is the difference?

+4
source share
2 answers

Management cache restrictions expire in any cache / HTTP / 1.1 client.

So, I assume that Google wants to cache the image for HTTP / 1.1, but not cache it at all for HTTP / 1.0.

I do not know why Google cares. I think they will want to cache the logo even for older customers.

+3
source

The reason is because Google wants the user to cache the image, but not intermediate shared caches (hence the private directive).

Many intermediate cache systems may be deprecated and ignore new HTTP features (such as the cache control header), so this approach forces them not to cache the resource (via the expires header). For other agents that understand both, cache management overrides end with a header.

This is a common practice mentioned in rfc2616 sec14.9.3

The origin server may wish to use a relatively new HTTP cache management function, such as the "private" directive, on the network, including older caches that do not understand this function. The origin server will need to combine the new function with the Expires field whose value is less than or equal to the Date value. This will prevent incorrect caching of responses to older caches.

0
source

Source: https://habr.com/ru/post/1345252/


All Articles