[Super Cache] Prevent deleting freshly preloaded files when GC time set to 0#30052
[Super Cache] Prevent deleting freshly preloaded files when GC time set to 0#30052thingalon wants to merge 5 commits into
Conversation
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Super Cache plugin:
|
pyronaur
left a comment
There was a problem hiding this comment.
Maybe the code should be updated to match the debug message?
donnchawp
left a comment
There was a problem hiding this comment.
Good catch. I wonder if it would be better to put the $cache_max_time check at the top of prune_super_cache instead? It would save traversing down the directories. But we'd have to check everywhere else we use prune_super_cache().
Or in wp_cron_preload_cache we set the global $cache_max_time variable to the current time minus the filemtime of "preload_mutex.tmp". That file is created when preloading starts. Set that before calling prune_super_cache() at line 3248 and preloaded files should be safe.
Co-authored-by: Nauris Pūķis <hi@pyronaur.com>
I thought about doing this, but I wasn't sure about the If that's not a consideration, then I would advocate for this. :)
This is also a very clever idea. I like that this would cause the preload system to clean out irrelevant files if you (for example) deleted a category since the last refresh. We'd want to add a buffer when calculating a However, this would mean that we'd delete any cached content that isn't preloaded. So cached search results with a GET param of |
|
I made a couple of changes in b1532bb based on @donnchawp 's suggestions:
Based on my testing, this fixes the issue, and preload should still clean out unused files after a long time. :-) |
|
I think we can close this. The mass deletion of files seemed to be caused in part by how slow that person's server was, but we've made changes elsewhere to speed up preload or at least make it more reliable on slow servers. |
Fixes https://wordpress.org/support/topic/preload-mode-skips-caching-pages-or-deletes-already-cached-pages
When preloads finish,
prune_super_cacheis called to clean out leftovers. Unfortunately, if$cache_max_timeis set to 0, preload will delete any files at least one second old - which frequently includes preloaded files. It causes intermittent post-preload disappearances.This PR fixes this by ensuring the prune process will not delete files based on mtime if
$cache_max_timeis 0.Proposed changes:
$cache_max_timeis set to 0.Other information:
Jetpack product discussion
n/a
Does this pull request change what data or activity we track or use?
no
Testing instructions: