Can Polly's Caching Policy cache selectively based on response? (eg cache only 200ok http responses)
See original GitHub issueIs Polly able to cache selectively based off of parameters like response code, response headers, etc
I could not find any documentation on what types of responses Polly decides to cache, or whether it’s possible to cache selectively based on attributes like the response code. Right now a workaround I’ve tried is using ResultTtl to vary the ttl based on response code, and setting a very short ttl for non 200 responses.
Is there any good way to have the cache policy ignore all responses that are not 200?
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Dynamic caching policy with Polly
If you just want to selectively cache for a specific response type, e.g. HttpResponseMessage , then that is actually not too difficult and...
Read more >Selectively Caching a HttpResponseMessage with Polly
This article will demonstrate how to selectively cache HttpResponseMessages based on the Http StatusCode of the response.
Read more >Caching
Using the advanced per-endpoint approach, you can selectively cache the responses to all requests, only those from specific paths or only responses with ......
Read more >Selectively Caching Values Inside HttpResponseMessage ...
This final post will show how to selectively cache values inside the response based on the status of the response.
Read more >HTTP caching - MDN Web Docs
The HTTP cache stores a response associated with a request and reuses the stored response for subsequent requests.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@lindstromhenrik You can convert
MemoryCacheProvider
to a version generic inTResult
usingas described in the MemoryCacheProvider documentation.
As
ResultTtl<TResult> : ITtlStrategy<TResult>
andITtlStrategy<TResult>
does not extendITtlStrategy
it may be worth to point out that the cache provider need to implementIAsyncCacheProvider<TResult>
, i.e it is incompatible with for example theMemoryCacheProvider
.