sourcelevel / faraday-http-cache

A Faraday middleware that respects HTTP cache
Other
343 stars 86 forks source link

Must-revalidate directive #100

Closed jstastny closed 4 years ago

jstastny commented 6 years ago

must-revalidate directive seems to be treated same as no-cache in the code: https://github.com/plataformatec/faraday-http-cache/blob/02274d8639f80ec3821d8efa9a824213882443ab/lib/faraday/http_cache/response.rb#L53

This does not seem to be in line with what the MDN Documentation says:

The cache must verify the status of the stale resources before using it and expired ones should not be used.

The way I understand it, the important word here is the "stale", which is the difference between this and the no-cache. This SO gives a nice discussion, coming to the same conclusion: https://stackoverflow.com/questions/18148884/difference-between-no-cache-and-must-revalidate

jstastny commented 6 years ago

An example of endpoint, which should be cacheable according to Google is https://www.googleapis.com/oauth2/v1/certs

Is has to following headers:

alt-svc: quic=":443"; ma=2592000; v="44,43,39,35"
cache-control: public, max-age=23880, must-revalidate, no-transform
content-encoding: gzip
content-length: 1563
content-type: application/json; charset=UTF-8
date: Fri, 16 Nov 2018 21:20:40 GMT
expires: Sat, 17 Nov 2018 03:58:40 GMT
server: ESF
status: 200
vary: Origin
vary: X-Origin
vary: Referer
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block