Edge case can lead to blank page being served
-
On our website, we have encountered an edge case where WP Super Cache occasionally serve blank pages to users.
The problem is that the
wp_cache_serve_cache_file()
function doesn’t check if any content was successfully read from the cache file.This scenario only happens when external processes remove the cached files. In our case this happens from time to time because we’re using a NFS file system with two front-end servers that both access the files (the entire web root is on the NFS).
But this means that a cache file can disappear between the call to
file_exists()
and the call tofile_get_contents()
. And in this situation, the empty string is then echo’ed.To fix this, please consider to change line 304-305 of wp-cache-phase2.php from:
echo $cachefiledata;
exit();To something along these lines:
if ($cachefiledata === false) {
wp_cache_debug( 'The wp-cache file could not be read. Must generate a new one.' );
return false;
}
echo $cachefiledata;
exit();Thanks in advance.
- You must be logged in to reply to this topic.