• Resolved School Reading List

    (@schoolreadinglist)


    Hi, over the past week we’ve noticed a strange problem.

    When a page or a post or a category is updated, the entire HTML cache is flushed.

    This is odd since our cache system WP Fastest cache is set to not clear the cache when posts or pages are changed.

    We’ve troubleshooted for plugin conflicts.

    When we disable Autoptimize the problem resolves.

    We found this code snippet:
    add_filter(‘autoptimize_filter_main_hookpagecachepurge’,’__return_false’);

    We added it to our child theme functions.php, but unfortunately, it did not resolve the problem.

    We read the WP Fastest Cache web FAQ and checked the plugin logs which reveal this command being sent to clear the cache:

    “26-05-2021 @ 14:01:32 flushPageCache”

    when a post was updated. This occured when WP Fastest Cache and Autoptimize were both enabled.

    However, when we disabled Autoptimize and tried updating a post, no “flushPageCache” command was sent or logged and the cache was not cleared.

    Please could you let us know how to fix this? We run a static site, so we don’t want anything in the cache to be cleared unless we manually command it.

    Many thanks for your help.

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

    (@optimizingmatters)

    *something* (a plugin or your theme? is it Divi by any chance?) must be triggering AO’s cache to be cleared schoolreadinglist .. :-/

    Thread Starter School Reading List

    (@schoolreadinglist)

    We don’t use DIVI.

    Literally changing one word on a post and updating is causing the entire HTML cache to be cleared.

    When Autoptimize is deactivated the problem goes away.

    Please can you help?

    Thread Starter School Reading List

    (@schoolreadinglist)

    To be clear, it is not AO’s cache that is being cleared, it is cache generated by WP Fastest cache – ie every chached html page. AO is causing this.

    Do you have a code snippet to turn this off?

    Thread Starter School Reading List

    (@schoolreadinglist)

    Check line 413 autoptimize/classes/autoptimizeCache.php

    add_action( 'autoptimize_action_cachepurged', array( 'autoptimizeCache', 'flushPageCache' ), 10, 0 );

    and lines 778-780 :autoptimize/classes/autoptimizeCache.php

           } elseif ( class_exists( 'WpFastestCache' ) ) {
                $wpfc = new WpFastestCache();
                $wpfc->deleteCache();

    You will see that Autoptimize is causing the entire WP Fastest Cache’s cache to be cleared when a post is updated. In the WP Fastest Cache log this is indicated: 26-05-2021 @ 14:01:32 flushPageCache

    Please advise on a fix. We don’t want a 3000 page website’s entire cache to be cleared when one word is changed! We have built our site arount Autoptimize and would hate to have to redevelop it with another optimisation plugin. Thanks for your time.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    * AO only asks page cache’s to clear their cache if AO’s cache was cleared, for the simple reason that otherwise you would have pages in cache that refer to Autoptimized files that were removed, resulting in badly broken pages which we do not want (so no, there is no code snippet).
    * AO never clears it’s own cache, so something (theme/ plugin) is doing this

    the only good solution is finding out what (theme? a plugin) is clearing AO’s cache upon page/ post publication, as that is the root of all problems here.

    Thread Starter School Reading List

    (@schoolreadinglist)

    Sorry, but you have not understood the issue.

    Nothing is “clearing AO’s cache”

    AO

      is clearing WP Fastest Cache’s cache.

      We need to prevent AO from clearing the cache.

      I hope you understand the issue. WP Fastest Cache’s chache is being cleared – uncommanded – by your plugin.

      Please read our previous post which explains this, identifies the code in your plugin responsible and provides log file proof.

      Thanks.

    Thread Starter School Reading List

    (@schoolreadinglist)

    I’d also like to add that you will be able to replicate the issue with a clean install of WP 5.7, and just the WP Fastest Cache and Autoptimize plugins installed and active.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    AO *never* acts on page caches unless it’s own cache is cleared (https://github.com/futtta/autoptimize/blob/beta/classes/autoptimizeCache.php#L405-L414 is part of the autoptimizeCache’s clearall method, which is what is called to clear AO’s cache)

    nothing in AO’s codebase acts on page/ post publication schoolreadinglist.

    Believe, I have a pretty good idea how AO works ??

    Thread Starter School Reading List

    (@schoolreadinglist)

    Sorry, but it is your plugin causing the issue.

    As I explained earlier, we’ve replicated with a fresh install, default theme, and just WP Fastest Cache and Autoptimize installed.

    When Autoptimize is deactivated, the issue is resolved.

    There is no doubt, I’m afraid, and I’m really sorry you don’t seem to want to pursue this.

    We’ll use a different optimization plugin going forward.

    Thanks for your time.

    Thread Starter School Reading List

    (@schoolreadinglist)

    A further proof of the bug:

    If you comment out these lines in the autoptimize cache php file:

    // Cache was just purged, clear page cache and allow others to hook into our purging...
            if ( true === $propagate ) {
                if ( ! function_exists( 'autoptimize_do_cachepurged_action' ) ) {
                    function autoptimize_do_cachepurged_action() {
                        do_action( 'autoptimize_action_cachepurged' );
                    }
                }
                add_action( 'shutdown', 'autoptimize_do_cachepurged_action', 11 );
                add_action( 'autoptimize_action_cachepurged', array( 'autoptimizeCache', 'flushPageCache' ), 10, 0 );
            }

    The issue resolves. .

    Crucially, if you then manually purge the autoptimize cache from the admin bar, the WP Fastest Cache DOES NOT clear (if the above code is commented out). This proves that it is not a third party calling Autoptimize to clear AO’s cache thereby clearing WP Fastest Cache’s cache, as you suggested. It is in fact AO clearing WP Fastest Cache’s cache whenever the slightest change is made.

    To stress how important this is – if a user has autoptimize installed with this bug, and uses a CDN, Cloudflare, or Cloudfront etc with paid per request pricing, then Autoptimize clearing an entire site’s cache uncommanded will cause a collosal cost increase in CDN bills as the entire site preloads/reloads.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    I mean, you obviously can read code as you are copy/pasting it yourself, no? So in that case look just a bit higher up and you cannot but see that the code you’re mentioning is part of AO’s clear cache functionality (it’s even in the comment you pasted; // Cache was just purged), no? This code does not, ever, get triggered but in an AO clear cache scenario and AO _never_ clears it’s own cache and when AO’s cache gets cleared, the page cache _has_ to be purged as well.

    So I cannot but re-iterate; something is clearing AO’s cache and you will need to find out what that *something* is or indeed use a different optimization plugin, which you obviously are entirely free to do.

    That, I’m afraid, is all I can do for you.

    frank

    Thread Starter School Reading List

    (@schoolreadinglist)

    Ok. We can see that you either don’t or don’t want to understand the issue. We’ll use another plugin. This thread can be closed.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Autoptimize is causing thentire html cache to be cleared when a post is updated’ is closed to new replies.