Support » Plugin: Autoptimize » Full page caching

  • Resolved jiggaman


    General question and recommendations on using full page edge caching with cloudflare. Have browser cache set to 8 days, and edge caching set to 30.

    I do updates to my theme occasionally, but on all version updates, requests to any css / js files have ver=something

    I am using autoptimize, I am noticing, what seems random, that many time the autoptimize created files will 404 on both css and js.

    Can you possibly describe what is happening and possibly suggest a solution to properly edge cache with cloudflare while using your plugin. I run a lot of sites on a single multisite server, so when I update the theme it updates all the sites (which are domain mapped)

    So looking for an easy way to manage things. Any suggetions appreciated, thanks frank!

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Optimizing Matters


    If you’re getting 404’s on the AO’d CSS/ JS, that implies the AO cache somehow was cleared (by clicking “save options & clear cache” or by some cronned job clearing AO cache -which AO does not do by itself- or another plugin calling autoptimizeCache::clearall() ) without your full page cache having been so.

    The result; your cached HTML has references to non-existant AO’ed JS/ CSS.

    The solution; making sure the AO cache does not get cleared OR clearing your CloudFlare page cache.

    hope this helps,

    Thanks for the quick response, the theme is DIVI. IN divi i can see that it is indeed making use of autoptimizeCache::clearall() in the file: core/components/init.php at line 158.

    It looks like this:

    if ( ! function_exists( 'et_core_clear_wp_cache' ) ):
    function et_core_clear_wp_cache( $post_id = '' ) {
            if ( ! wp_doing_cron() && ! et_core_security_check_passed( 'edit_posts' ) ) {
            try {
             // some various other plugin rules
             // ..
             // ..
                    if ( is_callable( 'autoptimizeCache::clearall' ) ) {
            } catch( Exception $err ) {
                    ET_Core_Logger::error( 'An exception occurred while attempting to clear site cache.' );

    So in my child theme…its very easy to rewrite et_core_clear_wp_cache.

    In the edge caching scenario, what do you think would be the best way to rewrite it.

    Also of note, in the code i can see references to wp-rocket and w3 cache having the ability to clear cache on per-post id basis, does your plugin have that ability as well? Ie something similar to: rocket_clean_post( $post_id ) or do_action( ‘w3tc_flush_post’, $post_id ) ect

    Plugin Author Optimizing Matters


    Ah, Divi … see

    AO does not have a purge per ID, as optimized CSS/ JS can (and generally will) be reused on multiple pages.

    The best way would be to stop Divi clearing AO’s cache entirely. I consider it a serious bug (based on a fundamental misunderstanding of what AO does) :-/

    Interesting, okay I will make that adjustment in my child theme. That said, say divi contact form changes on an update. I’m assuming that after i make my child theme adjustment, that aupotimize will see the updated js and then create an new autoptimized file?

    Plugin Author Optimizing Matters


    Iā€™m assuming that after i make my child theme adjustment, that aupotimize will see the updated js and then create an new autoptimized file?

    entirely correct šŸ™‚

    Can I ask you something @jiggaman ?
    I assume you are doing cache everything with a page rule in cloudflare. But when you publish a new post cloudflare won’t clear the cache (for home and other archives). So how do you deal with it? Just manually clear all caches each time?

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.