kornelski / http-cache-semantics

RFC 7234 in JavaScript. Parses HTTP headers to correctly compute cacheability of responses, even in complex cases
http://httpwg.org/specs/rfc7234.html
BSD 2-Clause "Simplified" License
244 stars 27 forks source link

Cache 301 redirect with a default timeout #29

Open gajus opened 4 years ago

gajus commented 4 years ago

Currently 301 redirects are not cached at all unless the website returns a satisfying cache-control header. This is not how browsers work.

https://stackoverflow.com/questions/9130422/how-long-do-browsers-cache-http-301s

There should be a setting to cache 301 redirects for an arbitrary default time.

kornelski commented 4 years ago

The spec says:

https://tools.ietf.org/html/rfc7231#section-6.4.2

A 301 response is cacheable by default; i.e., unless otherwise indicated by the method definition or explicit cache controls (see Section 4.2.2 of [RFC7234]).

So caching it would be a good idea indeed. It can probably be similar setting to the default cache time heuristic.