Thank you, dear dev, for the plugin hooks! But if you like you’re free to integrate it in your plugin.
Sweeet! thank you. I’ll add this in soon. Sorry haven’t been checking the forums lately.
Hey Benjamin,
Could you give me an example when autoptimize’s cache should be cleared when updating menus, widgets, or using the customizer? It seems like only the css and js is cached and I can’t think of any time when those files are updated outside of development.
Good point. Well, CSS and JS may change when WordPress, a theme or a plugin is updated – not sure if you have covered this use case yet?
Actually there is a small problem of my current approach of deleting the optimized files as well. In very rare cases the Cache delivered an old HTML, and before the CSS/JS-Files are loaded the cache is purged, and autoptimize changes the filenames if the content has changed, thus the HTML rendered with 404 for CSS/JS. Not good. So actually it would be better to defer the purging of the autoptimizer for some seconds via wp-cron.
Oh actually clearing the cache of this should not be essential, because the filename contains a hash that changes with the content, so new content -> new files. Maybe you just add my gist to your readme for the developer use case.