Cache Preload Force Refresh
-
Thanks a lot for this great plugin. We are using memcached for page caching.
We are inspecting page cache functions in order to find out what happens when the awesome cache preload feature is used. As far as we see, cache preload does not force a new page cache to be created if there is an existing cached version of the page.
If that is true, a time gap comes up between expiration of the existing cache and cache preload. What we need is to have a cached version of the page anytime by overwriting and refreshing the existing cache before it expires.
Internals: The class W3_PgCache controlling this process uses _can_cache() and _can_cache2() functions to decide. _can_cache() is used for reading existing cache, _can_cache2() is used for writing a new cache. _can_cache2() checks if _can_cache() is true, so if _can_cache() is false, neither existing cache is read, nor a new cache is written.
What we need is to skip reading but write a new cache. For our quick and dirty tests, we changed the user agent in W3_Plugin_PgCacheAdmin->prime() when calling the requested page and checked the user agent in W3_PgCache->process() in order to skip only reading but not writing the cache. So we just changed the line
if ($this->_caching) {
to
if ($this->_caching && !(isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] === 'RELOAD')) {
This method seems to be working for us.
We think this feature may be implemented as an option as forcing a new cache frequently will consume more resources for priming the cache which may not be preferred by everyone. Using the user agent string was the simplest way to test this, a better method can be implemented.
Thank you.
- The topic ‘Cache Preload Force Refresh’ is closed to new replies.