Skip to content

Add conditional cache preference to http requests

If we have a cache that's older than 7 days, assume that it's out of date and actually try again. If it's younger than that, assume that it's just the same, and prefer our cached version, if we have one.

The logic here is an attempt at striking a balance between using our cache to its fullest potential (as in, reducing server-side load and network roundtrips in general) while also handling the situation where the information that we are fed about the cache is not entirely correct (such as the case where we're told there's no expiration date, but the data in fact does change). 7 days seems a sensible sort of deadline for that, though we could change that later if we need to.

This was born out of a discussion on another kns review[1]

Assume that no cache expiration time will be longer than 7 days, but otherwise prefer the cache This is mildly hacky, but if we don't do this, we end up with infinite cache expirations in some cases, which of course isn't really acceptable... See ed62ee20 for a situation where that happened.

[1] !166 (comment 394067)

Edited by Dan Leinir Turthra Jensen

Merge request reports