Skip to content

Conversation

@ScottPolhemus
Copy link

This PR provides a mechanism for "revalidating" cache contents on a per-request basis. When a request contains the x-apicache-revalidate header, we skip loading from the cache (similar to a cache "bypass") but still make the response cacheable in order to update the cache store with fresh content.

I've found this to be useful in cases that would otherwise require manually clearing the cache before sending a new request in order to allow fresh content to be stored. In particular, I am implementing a "stale-while-revalidate" caching strategy in my application which serves stale content while revalidating in the background when the cached response is close to expiry, so that subsequent requests will receive more up-to-date content without having to incur the full processing overhead before sending a response to the client.

Note: I realized after-the-fact that this essentially duplicates the functionality from #220, which restored the original behavior for x-apicache-force-fetch which was regressed in #65. I personally find revalidate to be a more explicit description for the command (and less likely to be confused with bypass), but would be just as happy to see #220 merged in to restore this feature.

@coveralls
Copy link

coveralls commented May 14, 2021

Coverage Status

Coverage increased (+0.008%) to 97.546% when pulling eb1c67f on ScottPolhemus:revalidate into 3ae6fe7 on kwhitley:master.

@olsonpm
Copy link

olsonpm commented Apr 4, 2022

I've been looking for this functionality in an express/redis lib and came across this. Any reason not to use the existing no-cache request header for this purpose ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants