Learn about Centmin Mod LEMP Stack today
Register Now

Cache Everything Wordpress Cloudflare

Discussion in 'Web Development & Web Performance' started by adamus007p, Oct 17, 2022.

  1. adamus007p

    adamus007p Member

    357
    18
    18
    Feb 8, 2019
    Ratings:
    +35
    Local Time:
    4:27 AM
    Hello Guys,

    I followed a great tutorial created by @eva2000 https://blog.centminmod.com/2020/09/06/203/wordpress-cache-enabler-advanced-full-page-caching-guide/

    But after it I do not see that full page is cached.

    I read more in the guide:

    By default Cloudflare only caches static content files like images, css and js and doesn’t cache dynamically generated HTML files like WordPress blog pages unless you tell it specifically to do so via ‘Cache Everything’ page rules



    Is it mean that I need to write some extra rules on Cloudflare side to have a really full cache?

    May you share with your rules for Wordpress?

    I would be very grateful.
    Thank you very much. :)
     
  2. eva2000

    eva2000 Administrator Staff Member

    49,766
    11,447
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,789
    Local Time:
    1:27 PM
    Nginx 1.21.x
    MariaDB 10.x
    2 different full page HTML caches mentioned

    1. Wordpress Cache Enabler Plugin guest full HTML page caching is at Centmin Mod server level

    2. Cloudflare Cache Everything is at Cloudflare CDN cache level and by default isn't guest vs logged in user aware unless you had Cloudflare Business or Enterprise plan bypass cache on cookie page rule mentioned at https://blog.cloudflare.com/caching-anonymous-page-views/. Recently Cloudflare announced Cache Rules which support such bypass cache on cookie at Cache Rule level for all CF customers https://developers.cloudflare.com/cache/about/cache-rules/. Essentially, you need to define which cookies will bypass Cloudflare CDN cache so caching HTML pages only applies to guests and not logged in users.

    Centmin Mod is provided as is, so rest is up to you.
     
  3. adamus007p

    adamus007p Member

    357
    18
    18
    Feb 8, 2019
    Ratings:
    +35
    Local Time:
    4:27 AM
    Hello @eva2000 thank you for your response.

    Have you test Cache Rules vs CF Workers?
    Is it possible to do the same using just Cache Rules?
     
  4. eva2000

    eva2000 Administrator Staff Member

    49,766
    11,447
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,789
    Local Time:
    1:27 PM
    Nginx 1.21.x
    MariaDB 10.x
    Cache Rules like Page Rules have a set of things they can do. CF Workers can do the same but some more i.e. CF Workers can cache time (edge cache TTL) below the minimum of each CF plan regular cache edge TTL. Edge cache TTL min for CF Free = 2hrs, Pro = 1hr, Biz and Enterpise can do down to 1second

    Cache Rules are new so still testing myself.
     
  5. adamus007p

    adamus007p Member

    357
    18
    18
    Feb 8, 2019
    Ratings:
    +35
    Local Time:
    4:27 AM
    Is it only one difference?

    cache time (edge cache TTL) - what is it use for?


    Have you test it?



    Finally I have found, I will pase here as someone can find it:
    https://support.cloudflare.com/hc/e...aching-Static-HTML-with-WordPress-WooCommerce
    Guide to HTML Full Page Caching with Cloudflare for WordPress

    and implement it.

    Now I will will install woocommerce and test it, later Workers.
     
    Last edited: Dec 8, 2022
  6. adamus007p

    adamus007p Member

    357
    18
    18
    Feb 8, 2019
    Ratings:
    +35
    Local Time:
    4:27 AM
    @eva2000 how to safe you billing card agains of robots using Workers?

    I know what someone showing here robots.txt but I can not use it.
    Ok I have found it in a post of @deltahf :)
    https://community.centminmod.com/th...xenforo-with-newrelic.22047/page-2#post-91639

    I have found apache-ultimate-bad-bot-blocker/robots.txt at master · mitchellkrogza/apache-ultimate-bad-bot-blocker
    Make it sense to have a such long list in robots.txt?


    Is there any list of firewall which could be used as good practise? Or any good practise regards Workers and safe money?

    Thank you for your time in advance.
     
  7. eva2000

    eva2000 Administrator Staff Member

    49,766
    11,447
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,789
    Local Time:
    1:27 PM
    Nginx 1.21.x
    MariaDB 10.x
    cache edge TTL is how long you want to cache to be saved for and served from CDN edge cache.

    Cloudflare Bypass cache on cookie was traditionally a Cloudflare Business plan feature but now supported in CF Cache Rules in beta via cookie field https://developers.cloudflare.com/cache/about/cache-rules/

    Not much you can do beyond rate limiting and only rate limiting that is useful on CF would be on Business and Enterprise and higher plans to rate limit beyond IP counting/increments.

    No need, with Cloudflare WAF/Firewall you can configure equivalent though you need higher paid plans to get more useful matching field support i.e. regex in CF Business or Enterprise plans. But even Pro should be a good start.

    Good read is in CF Developer documentation https://developers.cloudflare.com/ and their community forums to ask questions and search for answers https://community.cloudflare.com/ if you want to learn and do it yourself. Or other option is to pay and hire an expert :)
     
  8. adamus007p

    adamus007p Member

    357
    18
    18
    Feb 8, 2019
    Ratings:
    +35
    Local Time:
    4:27 AM
    Thank you @eva2000 for answers. Maybe it is little bit stupid question but what are benefits using Workers instead od a Full cache page?

    CF Cache Rules is it something else then Workers and Full cache page?
     
  9. eva2000

    eva2000 Administrator Staff Member

    49,766
    11,447
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,789
    Local Time:
    1:27 PM
    Nginx 1.21.x
    MariaDB 10.x
    Using your own Cloudflare Workers for guests full HTML page caching allows finer grain control over what you can cache and for how long and when to cache. For instance for this forum's Cloudflare Worker guest full HTML page cache I can vary the Cache TTL time based on URL requested i.e. sticky thread vs non-sticky thread and also by time of day i.e. off peak vs peak hour forum times.
    Yes from Cloudflare customer point of view these 3 are separate features that do similar things
    • Cloudflare Page Rule = cache everything (free/pro plans can't distinguish between guest/logged in cookie visitors only Business and higher plans with bypass cache on cookie page rules)
    • Cloudflare Worker custom guest full HTML page cache when you configure for such i.e. bypass cache on cookie
    • Cloudflare Cache Rules newest feature that users can use cache everything and configure bypass cache on cookie. Though from Cloudflare company point of view Cloudflare Cache Rules are actually built on Cloudflare's own custom CF Workers themselves :)
     
  10. adamus007p

    adamus007p Member

    357
    18
    18
    Feb 8, 2019
    Ratings:
    +35
    Local Time:
    4:27 AM
    Thank you for answer I am trying to understand the difference.


    For example:
    Bypass no_cache or wp-*|wordpress-*|comment_*| woocommerce_* in the bypass rule. You can achieve it. Am I right?

    upload_2022-12-8_19-8-24.png
    or more
    upload_2022-12-8_19-10-55.png
    For guests page will be cached, back-office will be no cached.

    Checkout will be no cached.
    It seems that you can do bypass cache on cookie also using a Page rules

    Do I understand correctly that doing it via Workers you can more programm it and more control?



    Have you @eva2000 make any tests regards performace. Normal Full Cache page and Workers?


    How Workers or how your deal with dynamic pages?
    Do you have any dynamic things on forum?
    Have you used some plugins, rewrite somethig or done via configuaration of Worker?

    I am thinking to add dynamic things to ajax and bypass this problem, but first I want to make research.

    I am sorry if my questions are stupid but I am learing. You and users here are my mentors :) Thank you for sharing you a links and knowlegde.
     
    Last edited: Dec 9, 2022
  11. eva2000

    eva2000 Administrator Staff Member

    49,766
    11,447
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,789
    Local Time:
    1:27 PM
    Nginx 1.21.x
    MariaDB 10.x
    Cloudflare Page Reules bypass cache on cookie is a Cloudflare Business or Enterprise plan feature.

    Pretty much the same performance wise but depends how how you write your CF Worker code.

    Cloudflare workers all cache and no cache logic needs for you to code/program like in Javascript etc
     
  12. adamus007p

    adamus007p Member

    357
    18
    18
    Feb 8, 2019
    Ratings:
    +35
    Local Time:
    4:27 AM
    @eva2000 how you check if cache works ok or not?
    Wordpress Cache Enabler Advanced Full Page Caching Guide - Centmin Mod Blog

    Next is prompt to whether you want Cache Enabler to include or exclude mobile and tablet devices from caching. Some WordPress mobile theme plugins may not be fully responsive in design so may have issues with caching. For this example, will exclude mobile/tablet devices from caching.


    You wrote that this local cache can make trouble with mobile devices. How mobile and not mobile devices works with Cloudflare cache, full cache page, workers?

    Is there any tools instead of manual testing, different devices, different browsers?
    Is there any tools for it? Instead of Google developer tools :)
     
    Last edited: Dec 9, 2022
  13. eva2000

    eva2000 Administrator Staff Member

    49,766
    11,447
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,789
    Local Time:
    1:27 PM
    Nginx 1.21.x
    MariaDB 10.x
    You want your web sites to be HTML responsive as Cloudflare CDN cache by default can't distinguish between mobile and desktop unless you tell it to do so i.e. via Cloudflare custom cache keys https://developers.cloudflare.com/cache/about/cache-keys/ - that guide is for Cloudflare Enterprise Cache Key Page rules which have more features to allow custom Cache Keys. Cache Key which use to be a Cloudflare Enterprise Page Rule feature but now is available as a Cache Rule optional option but more limited in customisation i.e. only can toggle cache by device on/off. To read up on Cloudflare Cache read https://developers.cloudflare.com/cache/

    Again good read is in CF Developer documentation https://developers.cloudflare.com/ and their community forums to ask questions and search for answers https://community.cloudflare.com/ if you want to learn and do it yourself. Or other option is to pay and hire an expert :)

    webpagetest.org https://community.centminmod.com/th...getest-org-for-page-load-speed-testing.13859/
     
  14. adamus007p

    adamus007p Member

    357
    18
    18
    Feb 8, 2019
    Ratings:
    +35
    Local Time:
    4:27 AM
    There will be a lot of reading but thank you :)