Closed lukechilds closed 7 years ago
Thanks. That's a good point.
but this simple solution leaves the old response in the cache, and I'm not sure if that's correct either. I suppose the ideal solution would also remove the old entry from the cache, but that starts getting into a bit too much detail for a basic example :/
Yeah, not a particularly likely scenario but just thought I'd bring it up as it is technically violating the RFC. (storing a non storable response)
I don't think keeping a stale cache entry is a violation of the RFC but if you wanted to account for it it's only two extra lines:
} else {
letsPretendThisIsSomeCache.del(newRequest.url);
But yeah, like I said, not a scenario that's particularly likely to occur so ¯\_(ツ)_/¯
.
Thanks. I'm going to leave it as-is. Hopefully people won't copy the example literally.
It's possible that a revalidated response should not be stored. e.g has
Cache-Control: no-store
header. Therefore it should be explicitly checked to see if it's storable rather than assuming it still is.