phantomas icon indicating copy to clipboard operation
phantomas copied to clipboard

Enhance caching detection

Open gmetais opened this issue 9 years ago • 1 comments

Hi,

I've been auditing nasty cache problems recently, and I've learnt some vicious things about caching headers:

  1. If a Date header is provided by the server, the browser uses it to calculate the expire date. The Date header should always respond with the hour of the request, but some badly configured proxies don't reset it and keep the date when they last refreshed their cache. So inside Phantomas, the TTL should be calculated using this header instead of new Date() when it's available.

  2. If the server provides an Age header, the browser also uses it to calculate the expiration date : TTL = max-age - age.

  3. If there is a Vary header and its is not Accept-Encoding, Host, User-Agent or any combination of these 3, than Internet Explorer will ignore the cache duration. Have a look here. See the update note at the end of the article? I've tested IE10 and IE11 and they have the same behavior as IE9.

The third point probably fits into the cachingDisabled metric, rather than creating a new metric.

gmetais avatar Jun 24 '16 14:06 gmetais

Point 1: makes sense.

As for the second point: I'd rather not consider Age response header. phantomas reports the caching policies from the "server perspective". Including Age in the equation would make these metrics not quite deterministic (i.e. depending on the time we hit the caching layer).

Point 3: definitely worth reporting (and yay for Internet Explorer "awesome" features :) )

Thanks, @gmetais! Have a nice weekend :)

macbre avatar Jun 24 '16 16:06 macbre