Asynchronous refreshing of caches
Feature description
Although the caching system that wraps RemoteRequest instances is built so that it supports serving stale content, it currently refreshes its cache synchronously, instead of serving that stale content.
For optimal performance, this should be changed, so that a visitor requesting a page that hits an expired cache doesn't block until the remote request was completed.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation brief
QA testing instructions
Demo
Changelog entry
Three possible ways this can be done:
1.) Cron job working off a queue that cache refreshes are queued into.
2.) Non-blocking loopback/AJAX request to trigger the cache refresh in a separate request.
3.) Attaching the refresh at the very end of the shutdown handler, after the connection to the client has been closed via flush() and/or fastcgi_finish_request().
All three mechanisms will require a locking mechanism of some sort, to avoid refreshing the cache multiple times.
Mechanisms 1.) & 2.) will require either a serializable command object or an endpoint to decouple the refresh work to be done from the current process.