-
Notifications
You must be signed in to change notification settings - Fork 22
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
Cache TTL seems to be overwritten by cache control headers #94
Comments
Hello @ungive that seems to be a bug. I will check in the core codebase and if that's true, I'll patch that and anyway I will write a unit test to be sure that doesn't happen. |
@ungive I remembered that darkweak/souin#424 was the reason of this behaviour. |
Unfortunately dropping the Cache-Control header is undesirable in my use case, as the source of it should have control over how long the response should be cached at most. Each response could theoretically have a different max-age value, some low, some too high. I just wanna cap it. I've solved it now by limiting the max-age on the server that delivers the response, which I fortunately can. Others might not have control over it though.
I don't quite understand what you mean by that. Do you mean the company Fastly? Do you mean that this is something that won't be fixed or that this just was a requirement for your use case once, so you implemented it like that? Thanks for the help so far! |
@ungive I'm reading again the RFC and it specifies
https://www.rfc-editor.org/rfc/rfc9111.html#name-calculating-freshness-lifet |
I suppose this would solve my problem:
https://www.rfc-editor.org/rfc/rfc9111.html#section-4.2.1-2.3 |
Here is the complete order
So that's
|
Right, 2. would be applied first, 3. wouldn't even be considered if max-age is set. The order surprises my a bit though imo 3. should come before 2., at least in this context here. Which makes me think that the RFC just suggests the maximum that is allowed to be used to cache a response, to give a guideline for writing a system that caches as much as possible (since that improves performance). In that case the order doesn't really matter, since max-age and Expires are synonymous. But with cache-handler and/or Souin I think we should have an option to limit how long responses are cached. In my case the origin server serves data I have no control over. It comes from users of my system. Theoretically my cache could be filled up over time if I don't enforce a maximum cache duration. On a side note, what happens if the cache uses too much memory? Can you configure a memory limit and/or will the cache evict cached responses if available RAM is low? |
I can make the About the sidetone, that's not handled by Souin directly but by the storers themselves. |
@ungive again from the RFC 😕 |
I have set my cache's TTL to 30 seconds:
The source responds with these headers:
The result is that the content is cached for 120 seconds, not 30 seconds.
Cache hit response (ttl > 30):
Is this intended behaviour? How can I limit the caching duration? I don't really see a way to do it with the available configuration options.
Thank you!
The text was updated successfully, but these errors were encountered: