Problem with Cloudflare and Autoptimize

Yup I use that this too, forgot to mention it :slight_smile: Helps when you update wp posts.

2 Likes

Is it possible to customize the way the automatic cache management work or not ? Because as i said i’m hesitating to choose this way or the WP Cloudfare plugin…

You mean CF wordpress plugin no way to customise it unless you know how to code/make changes and/or add your own custom code to purge via CF cache API. For example you can write a script to use CF cache purge API to just purge specific urls you point to. I do that so I can check the CF cache age of a url(s) and purge based on a defined cache age

./cf-purge.sh purge-url 20
build purge urls
https://domain.com/about/ 180
https://domain.com/category/news/ 180
https://domain.com/date/2019/07/ 181

purging:https://domain.com/about/ age:180
purging:https://domain.com/category/news/ age:180
purging:https://domain.com/date/2019/07/ age:181
purge status:true

You’ll need to find you own balance as to what mix of technologies and tools work for your specific usage cases on how you post/update Wordpress posts.

Yes i mean the CF wordpress plugin, sorry.

Thanks for the code, i will have a look at it. In the same time the main basics will do this ? ->>

Sadly,

the filter isn’t working on my site. I don’t know why though. My AO cache was purged during the night and I have again 404 from AO. I need to found why AO cache is purge. I thought it was WP Rocket, but maybe that’s something else. Any idea folks ? :slight_smile:

Please guys i have been following this trend, my website is not working fine with autoptimize yet. https://www.wikirise.com/

lease check and give me advice.

Thank you.

Wikirise is rendering without any visible errors and there are no alerts in the browser’s Console or Network view. Not to mention there’s no mention of autoptimize in any of the site’s code.

If you know how to install and configure and read auditd logs and have SSH root access to your server, you can setup a custom audit rule to monitor and watch your wp-content/cache directory for write and access activity to see what is operating on your cache directory at server level.

example to create and watch directory at wp-content/cache (I shortened the path for easier viewing, you should use full path to the directory) and assign auditd rule key named = wpcache

auditctl -w wp-content/cache -p wa -k wpcache

Then use auditd command tools to inspect all entries related to auditd rule key = wpcache

ausearch -k wpcache | aureport -f -i

Example of relevant entries when you manually purge Cache Enabler wordpress plugin which hooks into Autoptimize to clear it’s cache too

628. 04/30/2020 03:22:03 wp-content/cache/autoptimize/js/autoptimize_1796ee2df85fa4f783a9e9466c7de5d4.js unlink yes /path/to/php-fpm unset 23932
629. 04/30/2020 03:22:03 wp-content/cache/autoptimize/js/autoptimize_1796ee2df85fa4f783a9e9466c7de5d4.js.gz unlink yes /path/to/php-fpm unset 23933
630. 04/30/2020 03:22:03 wp-content/cache/autoptimize/js/autoptimize_snippet_0ec85f0bb596f28f6294162924650fbe.js unlink yes /path/to/php-fpm unset 23934
631. 04/30/2020 03:22:03 wp-content/cache/autoptimize/js/autoptimize_snippet_0ec85f0bb596f28f6294162924650fbe.js.gz unlink yes /path/to/php-fpm unset 23935
632. 04/30/2020 03:22:03 wp-content/cache/autoptimize/js/autoptimize_snippet_8ed6038a5dbf62380de72a681340afd3.js unlink yes /path/to/php-fpm unset 23936
633. 04/30/2020 03:22:03 wp-content/cache/autoptimize/js/autoptimize_snippet_8ed6038a5dbf62380de72a681340afd3.js.gz unlink yes /path/to/php-fpm unset 23937
634. 04/30/2020 03:22:03 wp-content/cache/autoptimize/css/autoptimize_4a8bc5d490127fba1e504524cfa205e6.css unlink yes /path/to/php-fpm unset 23938
635. 04/30/2020 03:22:03 wp-content/cache/autoptimize/css/autoptimize_4a8bc5d490127fba1e504524cfa205e6.css.gz unlink yes /path/to/php-fpm unset 23939
636. 04/30/2020 03:22:03 wp-content/cache/autoptimize/css/autoptimize_afd488c05c4337b040066e2469e32b0c.css unlink yes /path/to/php-fpm unset 23940
637. 04/30/2020 03:22:03 wp-content/cache/autoptimize/css/autoptimize_afd488c05c4337b040066e2469e32b0c.css.gz unlink yes /path/to/php-fpm unset 23941
638. 04/30/2020 03:22:03 wp-content/cache/autoptimize/css/autoptimize_snippet_7d2051e6c59f3598b17877bf41637ec4.css unlink yes /path/to/php-fpm unset 23942
639. 04/30/2020 03:22:03 wp-content/cache/autoptimize/css/autoptimize_snippet_7d2051e6c59f3598b17877bf41637ec4.css.gz unlink yes /path/to/php-fpm unset 23943
640. 04/30/2020 03:22:03 wp-content/cache/autoptimize/css/autoptimize_snippet_b014e0b450ff70eb961fb89ef1811356.css unlink yes /path/to/php-fpm unset 23944
641. 04/30/2020 03:22:03 wp-content/cache/autoptimize/css/autoptimize_snippet_b014e0b450ff70eb961fb89ef1811356.css.gz unlink yes /path/to/php-fpm unset 23945
642. 04/30/2020 03:22:03 wp-content/cache/autoptimize/css/autoptimize_snippet_ede122677f3faa68ee2619a549fae7da.css unlink yes /path/to/php-fpm unset 23946
643. 04/30/2020 03:22:03 wp-content/cache/autoptimize/css/autoptimize_snippet_ede122677f3faa68ee2619a549fae7da.css.gz unlink yes /path/to/php-fpm unset 23947
644. 04/30/2020 03:22:03 wp-content/cache/autoptimize//.htaccess unlink yes /path/to/php-fpm unset 23948
645. 04/30/2020 03:22:03 wp-content/cache/cache-enabler-advcache-cache-enabler.domain.com.json open yes /path/to/php-fpm unset 23949
646. 04/30/2020 03:22:03 wp-content/cache/cache-enabler-advcache-cache-enabler.domain.com.json open yes /path/to/php-fpm unset 23950
647. 04/30/2020 03:22:03 wp-content/cache/cache-enabler-advcache-cache-enabler.domain.com.json open yes /path/to/php-fpm unset 23951
648. 04/30/2020 03:22:03 wp-content/cache/cache-enabler-advcache-cache-enabler.domain.com.json open yes /path/to/php-fpm unset 23952
649. 04/30/2020 03:22:03 wp-content/cache/cache-enabler-advcache-cache-enabler.domain.com.json open yes /path/to/php-fpm unset 23953
650. 04/30/2020 03:22:04 wp-content/cache/autoptimize/.htaccess open yes /path/to/php-fpm unset 23954

when you first browse wordpress index page and Cache Enabler does full HTML page guest caching and also populates Autoptimize caches + creates gzip pre-compressed css/js files due to my Autoptimize Gzip companion plugin

652. 04/30/2020 03:23:44 wp-content/cache/autoptimize/js/autoptimize_snippet_0ec85f0bb596f28f6294162924650fbe.js.gz open yes /path/to/php-fpm unset 23967
653. 04/30/2020 03:23:44 wp-content/cache/autoptimize/js/autoptimize_snippet_8ed6038a5dbf62380de72a681340afd3.js open yes /path/to/php-fpm unset 23968
654. 04/30/2020 03:23:44 wp-content/cache/autoptimize/js/autoptimize_snippet_8ed6038a5dbf62380de72a681340afd3.js.gz open yes /path/to/php-fpm unset 23969
655. 04/30/2020 03:23:44 wp-content/cache/autoptimize/js/autoptimize_1796ee2df85fa4f783a9e9466c7de5d4.js open yes /path/to/php-fpm unset 23970
656. 04/30/2020 03:23:44 wp-content/cache/autoptimize/js/autoptimize_1796ee2df85fa4f783a9e9466c7de5d4.js.gz open yes /path/to/php-fpm unset 23971
657. 04/30/2020 03:23:44 wp-content/cache/autoptimize/css/autoptimize_snippet_7d2051e6c59f3598b17877bf41637ec4.css open yes /path/to/php-fpm unset 23972
658. 04/30/2020 03:23:44 wp-content/cache/autoptimize/css/autoptimize_snippet_7d2051e6c59f3598b17877bf41637ec4.css.gz open yes /path/to/php-fpm unset 23973
659. 04/30/2020 03:23:44 wp-content/cache/autoptimize/css/autoptimize_snippet_ede122677f3faa68ee2619a549fae7da.css open yes /path/to/php-fpm unset 23974
660. 04/30/2020 03:23:44 wp-content/cache/autoptimize/css/autoptimize_snippet_ede122677f3faa68ee2619a549fae7da.css.gz open yes /path/to/php-fpm unset 23975
661. 04/30/2020 03:23:44 wp-content/cache/autoptimize/css/autoptimize_snippet_b014e0b450ff70eb961fb89ef1811356.css open yes /path/to/php-fpm unset 23976
662. 04/30/2020 03:23:44 wp-content/cache/autoptimize/css/autoptimize_snippet_b014e0b450ff70eb961fb89ef1811356.css.gz open yes /path/to/php-fpm unset 23977
663. 04/30/2020 03:23:44 wp-content/cache/autoptimize/css/autoptimize_afd488c05c4337b040066e2469e32b0c.css open yes /path/to/php-fpm unset 23978
664. 04/30/2020 03:23:44 wp-content/cache/autoptimize/css/autoptimize_afd488c05c4337b040066e2469e32b0c.css.gz open yes /path/to/php-fpm unset 23979
665. 04/30/2020 03:23:44 wp-content/cache/autoptimize/css/autoptimize_4a8bc5d490127fba1e504524cfa205e6.css open yes /path/to/php-fpm unset 23980
666. 04/30/2020 03:23:44 wp-content/cache/autoptimize/css/autoptimize_4a8bc5d490127fba1e504524cfa205e6.css.gz open yes /path/to/php-fpm unset 23981
667. 04/30/2020 03:23:44 wp-content/cache/cache-enabler mkdir yes /path/to/php-fpm unset 23982
668. 04/30/2020 03:23:44 wp-content/cache/cache-enabler/cache-enabler.domain.com mkdir yes /path/to/php-fpm unset 23983
669. 04/30/2020 03:23:44 wp-content/cache/cache-enabler chmod yes /path/to/php-fpm unset 23984
670. 04/30/2020 03:23:44 wp-content/cache/cache-enabler/cache-enabler.domain.com chmod yes /path/to/php-fpm unset 23985
671. 04/30/2020 03:23:44 wp-content/cache/cache-enabler/cache-enabler.domain.com/index.html open yes /path/to/php-fpm unset 23986
672. 04/30/2020 03:23:44 wp-content/cache/cache-enabler/cache-enabler.domain.com/index.html chmod yes /path/to/php-fpm unset 23987
673. 04/30/2020 03:23:44 wp-content/cache/cache-enabler/cache-enabler.domain.com/index.html.gz open yes /path/to/php-fpm unset 23988
674. 04/30/2020 03:23:44 wp-content/cache/cache-enabler/cache-enabler.domain.com/index.html.gz chmod yes /path/to/php-fpm unset 23989

when you just purge Autoptimize cache it seems to be hooked into Cache Enabler too, so purges both caches

675. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_1796ee2df85fa4f783a9e9466c7de5d4.js unlink yes /path/to/php-fpm unset 24212
676. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_1796ee2df85fa4f783a9e9466c7de5d4.js.gz unlink yes /path/to/php-fpm unset 24213
677. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_snippet_0ec85f0bb596f28f6294162924650fbe.js unlink yes /path/to/php-fpm unset 24214
678. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_snippet_0ec85f0bb596f28f6294162924650fbe.js.gz unlink yes /path/to/php-fpm unset 24215
679. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_snippet_8ed6038a5dbf62380de72a681340afd3.js unlink yes /path/to/php-fpm unset 24216
680. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_snippet_8ed6038a5dbf62380de72a681340afd3.js.gz unlink yes /path/to/php-fpm unset 24217
681. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_4a8bc5d490127fba1e504524cfa205e6.css unlink yes /path/to/php-fpm unset 24218
682. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_4a8bc5d490127fba1e504524cfa205e6.css.gz unlink yes /path/to/php-fpm unset 24219
683. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_afd488c05c4337b040066e2469e32b0c.css unlink yes /path/to/php-fpm unset 24220
684. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_afd488c05c4337b040066e2469e32b0c.css.gz unlink yes /path/to/php-fpm unset 24221
685. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_7d2051e6c59f3598b17877bf41637ec4.css unlink yes /path/to/php-fpm unset 24222
686. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_7d2051e6c59f3598b17877bf41637ec4.css.gz unlink yes /path/to/php-fpm unset 24223
687. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_b014e0b450ff70eb961fb89ef1811356.css unlink yes /path/to/php-fpm unset 24224
688. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_b014e0b450ff70eb961fb89ef1811356.css.gz unlink yes /path/to/php-fpm unset 24225
689. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_ede122677f3faa68ee2619a549fae7da.css unlink yes /path/to/php-fpm unset 24226
690. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_ede122677f3faa68ee2619a549fae7da.css.gz unlink yes /path/to/php-fpm unset 24227
691. 04/30/2020 03:33:46 /wp-content/cache/autoptimize//.htaccess unlink yes /path/to/php-fpm unset 24228
692. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/.htaccess open yes /path/to/php-fpm unset 24229
693. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_snippet_0ec85f0bb596f28f6294162924650fbe.js open yes /path/to/php-fpm unset 24230
694. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_snippet_0ec85f0bb596f28f6294162924650fbe.js.gz open yes /path/to/php-fpm unset 24231
695. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_snippet_8ed6038a5dbf62380de72a681340afd3.js open yes /path/to/php-fpm unset 24232
696. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_snippet_8ed6038a5dbf62380de72a681340afd3.js.gz open yes /path/to/php-fpm unset 24233
697. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_1796ee2df85fa4f783a9e9466c7de5d4.js open yes /path/to/php-fpm unset 24234
698. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_1796ee2df85fa4f783a9e9466c7de5d4.js.gz open yes /path/to/php-fpm unset 24235
699. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_7d2051e6c59f3598b17877bf41637ec4.css open yes /path/to/php-fpm unset 24236
700. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_7d2051e6c59f3598b17877bf41637ec4.css.gz open yes /path/to/php-fpm unset 24237
701. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_ede122677f3faa68ee2619a549fae7da.css open yes /path/to/php-fpm unset 24238
702. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_ede122677f3faa68ee2619a549fae7da.css.gz open yes /path/to/php-fpm unset 24239
703. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_b014e0b450ff70eb961fb89ef1811356.css open yes /path/to/php-fpm unset 24240
704. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_b014e0b450ff70eb961fb89ef1811356.css.gz open yes /path/to/php-fpm unset 24241
705. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_afd488c05c4337b040066e2469e32b0c.css open yes /path/to/php-fpm unset 24242
706. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_afd488c05c4337b040066e2469e32b0c.css.gz open yes /path/to/php-fpm unset 24243
707. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_4a8bc5d490127fba1e504524cfa205e6.css open yes /path/to/php-fpm unset 24244
708. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_4a8bc5d490127fba1e504524cfa205e6.css.gz open yes /path/to/php-fpm unset 24245
709. 04/30/2020 03:33:46 /wp-content/cache/cache-enabler/cache-enabler.domain.com/index.html unlink yes /path/to/php-fpm unset 24246
710. 04/30/2020 03:33:46 /wp-content/cache/cache-enabler/cache-enabler.domain.com/index.html.gz unlink yes /path/to/php-fpm unset 24247
711. 04/30/2020 03:33:46 /wp-content/cache/cache-enabler/cache-enabler.domain.com rmdir yes /path/to/php-fpm unset 24248
712. 04/30/2020 03:33:46 /wp-content/cache/cache-enabler rmdir yes /path/to/php-fpm unset 24249
713. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_1796ee2df85fa4f783a9e9466c7de5d4.js unlink yes /path/to/php-fpm unset 24250
714. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_1796ee2df85fa4f783a9e9466c7de5d4.js.gz unlink yes /path/to/php-fpm unset 24251
715. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_snippet_0ec85f0bb596f28f6294162924650fbe.js unlink yes /path/to/php-fpm unset 24252
716. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_snippet_0ec85f0bb596f28f6294162924650fbe.js.gz unlink yes /path/to/php-fpm unset 24253
717. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_snippet_8ed6038a5dbf62380de72a681340afd3.js unlink yes /path/to/php-fpm unset 24254
718. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/js/autoptimize_snippet_8ed6038a5dbf62380de72a681340afd3.js.gz unlink yes /path/to/php-fpm unset 24255
719. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_4a8bc5d490127fba1e504524cfa205e6.css unlink yes /path/to/php-fpm unset 24256
720. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_4a8bc5d490127fba1e504524cfa205e6.css.gz unlink yes /path/to/php-fpm unset 24257
721. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_afd488c05c4337b040066e2469e32b0c.css unlink yes /path/to/php-fpm unset 24258
722. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_afd488c05c4337b040066e2469e32b0c.css.gz unlink yes /path/to/php-fpm unset 24259
723. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_7d2051e6c59f3598b17877bf41637ec4.css unlink yes /path/to/php-fpm unset 24260
724. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_7d2051e6c59f3598b17877bf41637ec4.css.gz unlink yes /path/to/php-fpm unset 24261
725. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_b014e0b450ff70eb961fb89ef1811356.css unlink yes /path/to/php-fpm unset 24262
726. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_b014e0b450ff70eb961fb89ef1811356.css.gz unlink yes /path/to/php-fpm unset 24263
727. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_ede122677f3faa68ee2619a549fae7da.css unlink yes /path/to/php-fpm unset 24264
728. 04/30/2020 03:33:46 /wp-content/cache/autoptimize/css/autoptimize_snippet_ede122677f3faa68ee2619a549fae7da.css.gz unlink yes /path/to/php-fpm unset 24265
729. 04/30/2020 03:33:46 /wp-content/cache/autoptimize//.htaccess unlink yes /path/to/php-fpm unset 24266

You should be able to use such auditd rule to find out when Autoptimize cache is written to (open) /purged (unset/unlink)

Thank you very much for your answer. Unfortunately, I clearly don’t have the skills to perform this manipulation. I will show my webmaster to see if he can do it and try to find out why the Autoptimize cache purges itself. One thing is sure is that yesterday when I purged the WP Rocket cache, it purged the Autoptimize cache too, so the two are linked. But there must be something else, that’s for sure.

I had only set the filter in my functions.php theme but I hadn’t set the option in WP Rocket to never purge the cache (to “0”), so I don’t know if that’s it. It’s done now.

For example i’m having the same problem on these pages if you can examin the page and tell me what you see :


except it’s a .css problem and not .js

Thanks for your help :slight_smile:

from WPT results https://www.webpagetest.org/result/200430_RJ_6f6f1d8548dffc450d51c474a600faea/2/details/#waterfall_view_step1, the missing AO optimised css with 404 do not have proper cache control headers set for browser cache expires and origin cache control is set to no-cache. However, that maybe due to serving the 404 not found request itself and may not be the cause but symptom

image

while working AO js have proper cache control headers set to public

image

Unfortunately, you’ll need to figure out how or why or when the AO cache is being purged.

Of course you can try just disabling WP-Rocket and see

Sadly for now, my host told me i can’t do that because it requires full root access in order to run. I will see what i can do then.

Thanks for having a look. You’re right i need to understand why and how AO cache is beoing purged. It’s the main problem, causing these 404.

Yes i could do that to test if the AO cache is still being purged. I asked at the dev team of AO why and how is it possible that with their filter AO cache is still being purges. They answered " someone directly calling autoptimizeCache::clearall() is not limited/ stopped by the fitler."
So i will have a look at this too.

It’s a long story :frowning:

I saw a broken page and a missing (404) AO css file. The page was cached by the CF colocation (CF Cache Status: HIT).

But then I added a pseudo-query string to see if it would request a new page from the origin, and I got the same broken page, the same missing AO css file, but this time around with a page that hadn’t been cached by CF.

So it seems the issue cannot be fixed with a Cloudflare solution, you must fix it at the origin. I’m not familiar with WP Rocket, but if you are open to change your caching plugin, I can say I’ve been using WP Supercache with AO and CF without any issues (except, I should mention, that Googlebot has its own cache and that will cause it to see broken pages at times, then complain on GSC that your site is not mobile friendly etc)

Hi again,

thanks for having a look. I don’t think the problem is on CF side, but I need to understand why AO cache is purged. For now, I have tested this search inside all my plugins and i found a relation wil bloom plugin and AO. Maybe that’s a start?

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.