Theoretically (and in my experience also in reality) Autoptimize’s cache does not need to be cleared with core/ plugin updates, because when minifiying AO compares (a hash) of the unminified source with the hashes in available the cache folder (e.g. autoptimize_single_xyz123.js for the previous version of whatever.js). if the contents of whatever.js changes, then the hash is different and this cache miss results in whatever.js being re-minified and cached with a different hash (autoptimize_single_abc456.js) 🙂
hope this clarifies,
frank
Thanks for the quick reply and insight! I hear you that this is typically the way it works.
In our case/environment (nginx page cache, redis object cache, cloudflare), almost all issues with updates are resolved once we clear the autoptimize cache, particularly with Gravity Forms. This is after we have already cleared all other caches, which does not resolve the issues but then the autoptimize clearing – which does not seem to fire automatically after those cache clears either – tends to fix everything.
strange; when the page caches (nginx/ cloudflare) are cleared the page will be re-created by WordPress which will trigger Autoptimize which _should_ see new (uncached) JS and recreate it. is this something you can reproduce on a staging environment so I can check out the HTML (and links to JS-files) there? Or can you perform an webpagetest.org test at the moment the site is broken, that could also gave some idea of what is happening?
autoptimize does have logic, however, to clear it’s own cache if a “known” page cache is cleared, see https://github.com/futtta/autoptimize/blob/beta/classes/autoptimizeMain.php#L280-L303
suppose you have nginx_cache_cleared
action, you could use the autoptimize_filter_main_pagecachepurgeactions
filter to also listen for that action like this (warning: untested code);
add_filter( 'autoptimize_filter_main_pagecachepurgeactions',
function( $clearcaches_array ) {
$clearcaches_array[] = 'nginx_cache_cleared';
return $clearcaches_array;
},
10,
1
);
Thanks Frank, I’ll try to do a deeper dive on this the next time we run some upgrades, I appreciate the snippet as well. Much appreciated!