Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


How To Achieve ~90% Cache Hit Ratio On Cloudflare?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

How To Achieve ~90% Cache Hit Ratio On Cloudflare?

Hello everyone!
How to achieve a high cache hit ratio with Cloudflare Free Plan?
Is it possible? and how did you do it all?
Thanks in advance! B)

«1

Comments

  • What do you need to cache? Images? Read this fascinating story: https://chevereto.com/community/threads/banned-from-cloudflare-image-hosting-against-tos.12383/ and read CF ToS.

  • m4num4nu Member, Patron Provider

    Wondering the same. Hit ratio on Bunny is usually 95% or more. Even for less popular files. CF maybe 60% or less.

    This always made me wonder why everyone puts their small website behind CF. If it still fetches files from the origin, as CF won't cache the site unless it's getting lots of traffic.

  • @m4nu said: Wondering the same. Hit ratio on Bunny is usually 95% or more. Even for less popular files. CF maybe 60% or less.

    Because not all visits had a non-expired cache of your site?
    you people can actually develop a cookie tracker and get statistics on this ezpz

  • EthanZouEthanZou Member
    edited January 2023

    @LTniger said:
    What do you need to cache? Images? Read this fascinating story: https://chevereto.com/community/threads/banned-from-cloudflare-image-hosting-against-tos.12383/ and read CF ToS.

    Thanks, sir
    I just found that my site is always in miss status with cloudflare cache. :#

  • @m4nu said: CF won't cache the site unless it's getting lots of traffic.

    Oh, I see. That's why. Thanks!

  • As to Browser Cache TTL, which one is better? 4 hours or a month? and why?

  • Try this plugin. They claim it is an alternative to Cloudflare's paid APO.
    https://wordpress.org/plugins/wp-cloudflare-page-cache/

    Thanked by 1ariq01
  • @kidrock said:
    Try this plugin. They claim it is an alternative to Cloudflare's paid APO.
    https://wordpress.org/plugins/wp-cloudflare-page-cache/

    Thanks!
    Any advise for Laravel?

  • @m4nu said: This always made me wonder why everyone puts their small website behind CF

    For me, cloudflare is primarily about security and DNS, and only then caching

    Thanked by 1crilla
  • @bench said:

    @m4nu said: This always made me wonder why everyone puts their small website behind CF

    For me, cloudflare is primarily about security and DNS, and only then caching

    Everything in free plan, except dns feature, is an illusion which bears null advantage for small sites.

    Thanked by 1m4nu
  • @LTniger said: Everything in free plan, except dns feature, is an illusion which bears null advantage for small sites.

    it is enough if you know how to configure, block bots, scanners, unnecessary spiders, certain asn, configure captcha for certain pages, etc.

  • @LTniger said:

    @bench said:

    @m4nu said: This always made me wonder why everyone puts their small website behind CF

    For me, cloudflare is primarily about security and DNS, and only then caching

    Everything in free plan, except dns feature, is an illusion which bears null advantage for small sites.

    Hmm, why?

  • https://blog.polyhaven.com/how-we-handle-80tb-and-5m-page-views-a-month-for-under-400/

    Cached (orange) vs uncached asset downloads
    Total 80TB a month with cloudflare

    • use full page cache, that is, cache everything.
    • use cf workers to cache and it only hits origin if the resource is not available in cache.
    • use tiered-caching feature as "ON"
    • on your html/php page, use cache-control header, s-maxage=xxxxxxxxxxx (seconds in month or year) so that the middle cache, like cdn, caches it for longest time as specified.
    • remove etag/timestamp headers from html.
  • @JasonM said:

    I've started to write my long story.
    But JasonM did it very compact and good.
    I just can add few cents, For more information check:
    https://developers.cloudflare.com/cache/about/default-cache-behavior/

    Thanked by 1JasonM
  • eDigitaleDigital Member
    edited January 2023

    @LTniger said:

    @bench said:

    @m4nu said: This always made me wonder why everyone puts their small website behind CF

    For me, cloudflare is primarily about security and DNS, and only then caching

    Everything in free plan, except dns feature, is an illusion which bears null advantage for small sites.

    hmm unless you know what you are doing:

    1) I use Super Page Cache for Cloudflare "Cache Everything" plugin and got 100% score on GTMetrix and the website load extremely fast.

    2) I replaced Wordpress cron with Cloudflare workers which do cron job every 1 min taking off the load on my backend server.

    3) As I ran Nginx/Apache backend, I encountered numerous bots scraping and visiting daily that I had to totally filtered off all traffic with Nginx access rule and block bots with user agents, restrict common WP uri paths and blank user agents with Cloudflare WAF security rules. I had almost zero malicious and scraping bots now, prior to that my stopbot plugin and Wordfence logs were full of bots entries.

    and I did this all for free.

    Thanked by 2kidrock bench
  • Likely impossible for free since you can't have intermediate caching without paying...you'd have to pay for Argo to get that.

    Alternatively use their edge storage solution, but that'll also cost you money.

  • inlandinland Member
    edited January 2023

    @LTniger said: What do you need to cache? Images? Read this fascinating story: https://chevereto.com/community/threads/banned-from-cloudflare-image-hosting-against-tos.12383/ and read CF ToS.

    You're scaring him away. CF ToS clearly mentions disproportionate percentage of images, movies, audio files or other non-HTML content. If you host a normal site and not an image/video hosting, there's nothing to be worried about. Hell, even if you just disregard the ToS, you'll find that Cloudflare is actually pretty generous with the traffic allowance.

    Even in the thread you link, they were using hundreds of terabytes per month for years on free tier before CF caught up. With that amount of traffic, some providers can kick you off your "unlimited" VPS or dedi that you pay real money for.

    Thanked by 1emgh
  • benchbench Member
    edited January 2023

    @inland said: You're scaring him away. CF ToS clearly mentions disproportionate percentage of images, movies, audio files or other non-HTML content. If you host a normal site and not an image/video hosting, there's nothing to be worried about. Hell, even if you just disregard the ToS, you'll find that Cloudflare is actually pretty generous with the traffic allowance.

    I have been passing through them for many years 30TB+ in the form of archives or videos, so far no problems and warnings

  • eva2000eva2000 Veteran
    edited January 2023

    @EthanZou said:
    Hello everyone!
    How to achieve a high cache hit ratio with Cloudflare Free Plan?
    Is it possible? and how did you do it all?
    Thanks in advance! B)

    Yes it's possible

    1. Re-define what requests you are measuring. So exclude all requests which you know can't or shouldn't be cache hits i.e. POST requests, non-200 HTTP status code i.e. 403/404 and URLs which you don't expect to be cached i.e. /login /contact /admin and then evaluate your cache hit rate on requests that are left over after the exclusions :) My Wordpress blog's HTML page Cloudflare cache hit rate = 99.8%
    2. then leverage Cloudflare Page Rules, Cache Rules and Transform Rules to create rules to cover static file requests which Cloudflare doesn't cache by default but you want cached and/or dynamic HTML pages which are for guests using Cache Rules with cookie bypass or Page Rules with bypass cache on cookie (CF Business or higher plans) or bypass cache on cookie via custom Cloudflare Worker caching
    Thanked by 2bench ariq01
  • raindog308raindog308 Administrator, Veteran

    @LTniger said: What do you need to cache? Images? Read this fascinating story: https://chevereto.com/community/threads/banned-from-cloudflare-image-hosting-against-tos.12383/ and read CF ToS.

    The amount of "I demand free service" entitlement demanded in that thread is hilarious.

  • @JasonM said: use cf workers to cache

    Many thanks, JasonM
    And how to use cf workers with my site?

    remove etag/timestamp headers from html

    So for what purpose?

  • @desperand said:

    @JasonM said:

    I've started to write my long story.
    But JasonM did it very compact and good.
    I just can add few cents, For more information check:
    https://developers.cloudflare.com/cache/about/default-cache-behavior/

    Thanks a lot and how to use cf workers to cache with laravel?

  • @eDigital said:

    @LTniger said:

    @bench said:

    @m4nu said: This always made me wonder why everyone puts their small website behind CF

    For me, cloudflare is primarily about security and DNS, and only then caching

    Everything in free plan, except dns feature, is an illusion which bears null advantage for small sites.

    hmm unless you know what you are doing:

    1) I use Super Page Cache for Cloudflare "Cache Everything" plugin and got 100% score on GTMetrix and the website load extremely fast.

    2) I replaced Wordpress cron with Cloudflare workers which do cron job every 1 min taking off the load on my backend server.

    3) As I ran Nginx/Apache backend, I encountered numerous bots scraping and visiting daily that I had to totally filtered off all traffic with Nginx access rule and block bots with user agents, restrict common WP uri paths and blank user agents with Cloudflare WAF security rules. I had almost zero malicious and scraping bots now, prior to that my stopbot plugin and Wordfence logs were full of bots entries.

    and I did this all for free.

    Sounds great and you use cf workers to do cron job? for what?

  • @hacktek said:
    Likely impossible for free since you can't have intermediate caching without paying...you'd have to pay for Argo to get that.

    Alternatively use their edge storage solution, but that'll also cost you money.

    Hmm, if so Bunny would be my last choice. :#

  • @inland said:

    @LTniger said: What do you need to cache? Images? Read this fascinating story: https://chevereto.com/community/threads/banned-from-cloudflare-image-hosting-against-tos.12383/ and read CF ToS.

    You're scaring him away. CF ToS clearly mentions disproportionate percentage of images, movies, audio files or other non-HTML content. If you host a normal site and not an image/video hosting, there's nothing to be worried about. Hell, even if you just disregard the ToS, you'll find that Cloudflare is actually pretty generous with the traffic allowance.

    Even in the thread you link, they were using hundreds of terabytes per month for years on free tier before CF caught up. With that amount of traffic, some providers can kick you off your "unlimited" VPS or dedi that you pay real money for.

    CF, YES! :#

  • @bench said:

    @inland said: You're scaring him away. CF ToS clearly mentions disproportionate percentage of images, movies, audio files or other non-HTML content. If you host a normal site and not an image/video hosting, there's nothing to be worried about. Hell, even if you just disregard the ToS, you'll find that Cloudflare is actually pretty generous with the traffic allowance.

    I have been passing through them for many years 30TB+ in the form of archives or videos, so far no problems and warnings

    30TB+ a month?

  • @eva2000 said:

    @EthanZou said:
    Hello everyone!
    How to achieve a high cache hit ratio with Cloudflare Free Plan?
    Is it possible? and how did you do it all?
    Thanks in advance! B)

    Yes it's possible

    1. Re-define what requests you are measuring. So exclude all requests which you know can't or shouldn't be cache hits i.e. POST requests, non-200 HTTP status code i.e. 403/404 and URLs which you don't expect to be cached i.e. /login /contact /admin and then evaluate your cache hit rate on requests that are left over after the exclusions :) My Wordpress blog's HTML page Cloudflare cache hit rate = 99.8%
    2. then leverage Cloudflare Page Rules, Cache Rules and Transform Rules to create rules to cover static file requests which Cloudflare doesn't cache by default but you want cached and/or dynamic HTML pages which are for guests using Cache Rules with cookie bypass or Page Rules with bypass cache on cookie (CF Business or higher plans) or bypass cache on cookie via custom Cloudflare Worker caching

    Nice! Thanks a lot and how to use Cloudflare Worker with my site?

  • Cache-Control: public, max-age=3600
    Cache-Control: private, max-age=3600

    What's the difference between public and private?

  • FatGrizzlyFatGrizzly Member, Host Rep

    @EthanZou said:
    Cache-Control: public, max-age=3600
    Cache-Control: private, max-age=3600

    What's the difference between public and private?

    I found this paragraph a few days ago, should be quite informative.

    The “public” response directive indicates that any cache MAY store the response whereas the “private” response directive indicates that the response message is intended for a single user and MUST NOT be stored by a shared cache.

Sign In or Register to comment.