-
Notifications
You must be signed in to change notification settings - Fork 385
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
Prevent cache polution #675
Conversation
Retrieving a feed with distinct cURL parameters such as user-agent might give different responses, which should not share the same cache. Follow-up and generalisation of simplepie#643 The code to get the cache filename is extracted in its own new fuction `SimplePie::get_cache_filename($url)` so that clients can easily get this information as well. Downstream PR: FreshRSS/FreshRSS#3502
// Append custom parameters to the URL to avoid cache pollution in case of multiple calls with different parameters. | ||
$url .= $this->force_feed ? '#force_feed' : ''; | ||
$options = array(); | ||
if ($this->timeout != 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those tests are to keep the best possible compatibility with existing cache filenames: if not using custom cURL options, the cache filenames should be unchanged
if (!empty($options)) | ||
{ | ||
ksort($options); | ||
$url .= '#' . urlencode(var_export($options, true)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The modified URL is still a valid URL, in case a custom cache_name_function()
might have such an expectation
could this be optional? I don't feel that changing your agent necessarily means you want to cache both versions, but this is enforcing it. I think you will also need to move |
<?php
$url = 'https://example.net/#one#two#three';
print_r(parse_url($url));
|
ok fair enough, I was thinking caches might grow unexpectedly from this change but that's really only a problem if you're changing the agent options a lot. thanks for the update! |
Retrieving a feed with distinct cURL parameters such as user-agent might give different responses, which should not share the same cache.
Follow-up and generalisation of #643
The code to get the cache filename is extracted in its own new function
SimplePie::get_cache_filename($url)
so that clients can easily get this information as well.Downstream PR: FreshRSS/FreshRSS#3502