cachecontrol
cachecontrol copied to clipboard
Cache content ignored if no date present
https://github.com/ionrock/cachecontrol/blob/master/cachecontrol/controller.py#L120 ff. seems to be ignoring cache entries that do not have a date header.
I think https://tools.ietf.org/html/rfc7232#section-2.4 allows sending etag without date; in that case, the cache content would never be used.
Also, I'm wondering why it's deleting a cache entry here; if a cache entry does not have the headers required to make it useful, wouldn't it be better to never enter it into the cache in the first place?
(I may be misunderstanding things, grossly; I'm currently looking only at the code that retrieves data from the cache, in cached_response.)
If I understand correctly, you can do this with a custom heuristic like this one.
Not sure what that heuristics is doing in the first place (it's been quite a while since I even looked into cachecontrol). It's not fixing the bug that cachecontrol enters data into the cache but never retrieves it, instead deletes it the next time around. (IIRC the code doesn't have a comment that explains why it's deleting stuff on that specific code path; I dimly recall that my knee-jerk reaction was "why doesn't it block the entry from being created in the first place? ... hmm, looks like the programmer did a keyhole fix instead of fixing the algorithm's problems here... not sure though, not enough commentary to properly infer what actually happened... ah well, shoot off a GH issue and see whathappens".)