AO itself never removes anything from its own cache, so the only thing I can think off is AO’s cache being cleared (either manually or by another plugin/ theme hooking into AO’s API or doing it on filesystem level) without the page cache being cleared?
frank
I have this same issue but I found what is responsible for that. Unfortunately this plugin have a cron job where files are deleting. I mean cron jon “ao_cachechecker” where function “autoptimizeCache::delete_advanced_cache_clear_artifacts()” deletes a good files, not only artifacts… It’s critical bug, please fix it asap.
ao_cachechecker
only checks cache size, but does not call delete_advanced_cache_clear_artifacts
or any related function; AO by design does never clear it’s own cache, it must be something else beherit ..
Take a look at your code π function cronjob() runs on this cronjob because you add action for it π And this function runs autoptimizeCache::delete_advanced_cache_clear_artifacts(); that removes files. No, it is not something else. I double checked it e.g. by manually runing cronjob ao_cachechecker.
hmmm … you’re right about delete_advanced_cache_clear_artifacts() being called from ao_cachechecker. forgot about that π
now although something _could_ go wrong there, it would be a pretty obscure bug; the delete_advanced_cache_clear_artifacts
function deletes files that were moved to a directory with a specific prefix as an alternative (faster) clear-cache method, but that alternative method is not used except when a filter is set. given no directories with that prefix exists, the function should not delete anything ..
but I’ll dive into the code tomorrow to see where thing *could* go wrong and if I find any look for ways to make this less likely.
OK, so did an in-depth review of the code in delete_advanced_cache_clear_artifacts
, which;
- reads the contents of the parent of the autoptimize cache folder (so default
wp-content/cache
)
- for each item in that array is checks if the filename has the prefix
autoptimize-
and if that item is a directory
- only if both conditions are true, it removes the entire directory
Based on this, I consider it next to impossible for this function to delete individual files in wp-content/cache/autoptimize/
except if you used a constant to rename the autoptimize cache-folder into autoptimize-<xyz>
, in which case the entire directory with the real cache would be removed and (shortly after) get recreated by normal AO logic (making it look like individual files were deleted).
Nevertheless I have added a check in said function to make sure it is only active when the “advanced cache clearing” is active as well, if only to ensure this logic isn’t executed when it isn’t needed and I changed the prefix from autoptimize-
into autoptimize-artifacts-
to make sure someone having set the constant to autoptimize-production
or so won’t have the real cache directory deleted.
You can download & test what will become AO26 from https://github.com/futtta/autoptimize/archive/beta.zip π
frank
Everything is working perfectly now π
hmmm … very bizarre, based on the code (even from before the changes made) this should not be happening.
but glad it’s now no longer an issue, some extra precautions never hurt as proven once again π