-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I "always cache", ignoring response cache headers? #116
Comments
Hi! I believe the custom controller is what you needed. Here is the example: import hishel
class AlwaysCacheController(hishel.Controller):
def is_cachable(self, request, response) -> bool:
return True
def construct_response_from_cache(self, request, response, original_request):
return response
client = hishel.CacheClient(controller=AlwaysCacheController()) The controller is responsible for validating the stored response in the You can also use storage TTLs with this custom controller because the controllers and storages are completely independent. I think it will be amazing to add an extension for such cases. Now that we have the |
The I'd have expected the TTL to run down independently, irrespective of whether there was a cache hit. In other words, ACTUAL
EXPECTED
|
The solution posted over at #85 (comment) seems to work the way I want. The only downside is the cache entry (in my case, in redis) never expires. I had to remove |
Actually, now that the For example, for filesystems, we use |
Resolved in #117 |
The endpoint I'm dealing with has
Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate
. However, I'd still like to cache the response, and take advantage of hishel's TTL (say 1min) before I hit the endpoint again.How do I ignore response headers, and make hishel always cache responses?
The text was updated successfully, but these errors were encountered: