-
Notifications
You must be signed in to change notification settings - Fork 0
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
Negotiate cache_expiration_time #26
Conversation
- `Cache-Control: max-age` minus `Age`, extendable by `$simplepie_cache_duration` - `Cache-Control: must-revalidate` will prevent `$simplepie_cache_duration` from extending past the `max-age` - `Cache-Control: no-cache` will return the current time - `Cache-Control: no-store` will return `0` - `Expires` but only if `Cache-Control: max-age` is absent
@Frenzie , @marienfressinaud, @Art4 and others: discussion welcome. At the moment SimplePie is not HTTP compliant when it comes to HTTP requests and caching. This PR addresses some of it. But I have some doubts. On my local tests, I see plenty of feeds responding with For instance, our own GitHub releases feed returns So on FreshRSS instances with many users, there is a good likelihood of having several users subscribing to the same feed(s) (for instance this GitHub release feed), and preventing the cache from being used by the following users during a refresh cron job would be a waste of resources - but potentially good for servers which care about download statistics. We could consider updating our heuristics based on e.g. Thoughts? |
At least on GH I would suspect it's closer to a mistake, intended to make sure the comments are up to date on a page like this one. But you can certainly think of scenarios where it would be intentional. Perhaps something like a server minimum cache time constant at 5 or 10 minutes by default? |
I have introduced Its default is 60s but can be set higher. But not obeying |
Changed logic, to account for the many servers disabling cache all-together. Simpler, and probably more pragmatic |
You don't think 24h sounds a bit short as a default maximum if the site is explicitly asking for it? :-) |
Maybe, but I am balancing that with users, who will believe that the refresh is broken... P.S.: And I can also see some feeds returning high values, which are most likely broken. |
Right, I'm not saying to just listen to whatever the feed might say, just that a few days still seems reasonable. But the point about users makes sense. |
For some unknown reason, I observe some strange feeds (e.g. https://gts-net.dk/feed/ ), which are returning a much higher
|
Oof. :-/ |
Seems to only make sense for CDNs
Another feed with same problem: https://www.smappee.com/blog/feed/
|
Well, when nginx is in the equation, it is often the culprit...
|
Workaround implemented: Allow servers to return a shorter cache duration for 304 responses, but not longer than the value in the 200 response |
Seems to work quite fine |
* SimplePie support for HTTP cache policies Discussion in FreshRSS/simplepie#26 * Bump SimplePie commit * Typos * Typos * Simpler logic * Explicitly disable cache for non-GET flows * Bump SimplePie commit * Bump SimplePie commit * Bump SimplePie commit * Bump SimplePie commit
Negotiate the cache expiration time based on the HTTP response headers.
Return the cache duration time in number of seconds since the Unix Epoch, accounting for:
Cache-Control: max-age
minusAge
, bounded by$cache_duration_min
and$cache_duration_max
Cache-Control: must-revalidate
will set$cache_duration
to$cache_duration_min
Cache-Control: no-cache
will returntime() + $cache_duration_min
Cache-Control: no-store
will returntime() + $cache_duration_min - 3
(to distinguish from no-cache if needed)Expires
likeCache-Control: max-age
but only if it is absentParameters:
$cache_duration
Desired cache duration in seconds, potentially overridden by HTTP response headers$cache_duration_min
Minimal cache duration (in seconds), overriding HTTP response headersCache-Control
andExpires
$cache_duration_max
Maximal cache duration (in seconds), overriding HTTP response headersCache-Control
andExpires