http-cache icon indicating copy to clipboard operation
http-cache copied to clipboard

Altering cache mode depending on response

Open eirnym opened this issue 1 year ago • 1 comments

I'd like to be able to alter caching mode depending on a response I get. Default implementation is already there, which uses HTTP headers to decide on that

E.g. I use a cache to hit an API endpoint and I'd like to handle errors properly (e.g. request limit), but force to cache for example 2xx responses, even http headers tell "no cache" to clear them later manually.

eirnym avatar Oct 12 '24 13:10 eirnym

I think this should be doable. When I get in to make the other updates this weekend (hopefully) I will play around with including the body as an argument.

06chaynes avatar Nov 08 '24 18:11 06chaynes

Been a while but adding this functionality in PR #115 via a new field in HttpCacheOptions called response_cache_mode_fn

06chaynes avatar Jul 25 '25 22:07 06chaynes