guzzle-cache-middleware
guzzle-cache-middleware copied to clipboard
Feature request: revalidate some stale caches in the background
It would be nice to have an option to refresh some stale caches in the background. With such mechanism, middleware could increment the overall application performance.
At least stale-while-revalidate
directive explicitly says about revalidating of responses in the background.
Beyond that, we could invent an explicit way to manage refreshable caches. For example:
Make a request:
// Possible way to mark a request as refreshable — add 'refreshable' to its config
$client = new Client($config + ['refreshable' => true]);
$client->get('https://example.com/resource');
Then, run as a scheduled job:
// Possible way to select requests for refreshing — filter caches with method/url
$magic->revalidateStaled(['https://example.com/']);
If @Kevinrob says this is possible and reasonble — I could try to make a PR?