• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
NameHero Blog

NameHero Blog

Web Hosting Tips & Resources From NameHero

  • Web Hosting
  • Reseller Hosting
  • Managed Cloud
  • Domains
  • Account
  • Blog Home
  • Categories

“Cache Everything” On Cloudflare The RIGHT Way

Bhagwad Park

Published on: March 25, 2019

Categories: Website Performance 2

Everyone knows that CDNs are only for static content. CSS, JS, images, and font files for the most part. The “static” is what makes CDNs efficient. The idea is that a piece of content needs to be retrieved only once per EDGE server (not once in general), and then users are served a copy of that file instead of from the origin.

It takes a while to “prime” or “warm” all the EDGE nodes – especially if your CDN provider has hundreds of servers all over the world. Each of them needs to be hit with at least one request for each static file before it’s available in the cache. This can take some time. Let’s see how much.

Requests Needed to Prime the Cache

Let’s say your CDN provider has 150 POP server locations. It’s not an unusual number. And let’s say you have 20 static files (a very conservative number). The total number of “unprimed” or “uncached” requests will be:

150*20 = 3000 requests

So 3000 requests will be served from your origin. Keep in mind that those 3000 requests will be slightly slower than a normal request because it’s going through an additional stop point along the way. Based on your traffic, it can take several days before you see the impact of a CDN on your site performance!

And if you ever clear the cache completely – say you change your CSS files, the whole process will start again.

Moral of the story: Don’t clear your cache often!

That’s Why Cloudflare’s “Cache Everything” Generally Doesn’t Work

Cloudflare is a very special CDN. It has a unique “cache everything” page rule, which includes the dynamic HTML. That drastically improves your Time to First Byte (TTFB) and server response times.

But only if your pages are already being cached at that particular EDGE server.

The previous calculation assumed only 20 static files. Lots of websites however, have hundreds of pages. And if we wanted to prime 150 POP locations with 400 page – well, that’s 60,000 requests! And considering that all CDNs purge their caches automatically when a file hasn’t been requested from a particular EDGE server for a while…you can see that the “cache everything” option can be a disaster.

Use Case Scenario for “Cache Everything” on Cloudflare

I’d explained in more detail in an earlier article why Cloudflare’s “Cache Everything” isn’t a good idea. And if you just turn it on and make it cache every page, you’ll have a pretty bad experience. Not to mention horrible problems with anonymous visitors accidentally seeing admin bars etc.

But it can work nicely in a specific situation.

Let’s say you have ONE page on your site that generates most of your revenue. Or all of it! One basic landing page which is the cornerstone of your revenue strategy. It need not contain the shopping cart itself but can lead to it. Or it converts really well.

I’ve found that we can speed up the delivery of this single page by using Cloudflare “Cache Everything” page rule. It will work under the following conditions:

  1. Contains static content that’s the same for all anonymous visitors
  2. Doesn’t change very often

Priming the Cache Efficiently

But sometimes the page will change. Let’s say once a week you make an update to it. We need to prime all the EDGE servers. What I do is I subscribe to Cloudflare’s “Argo” service which uses tiered caching. This means that under some circumstances, Cloudflare will be able to get a copy of your page from nearby POPs instead of directly from the origin server. This helps with the priming problem.

In addition, after making a change to my page, I log onto my VPN and ping my site from 6-7 locations around the world – one in each continent at least. I usually choose:

  1. US
  2. South America
  3. Europe
  4. Middle East
  5. South Africa
  6. India
  7. Hong Kong

This way, I get my page onto all distant caches, and maximize the changes of Argo’s tiered cache system picking up my page from one of these POP servers instead of from my origin. After doing this for a while, my server response times and TTFB have increased dramatically!

Bhagwad Park Profile Picture
Bhagwad Park

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!

Reader Interactions

Comments

  1. Victor says

    December 11, 2020 at 2:36 pm

    Hello Bhagwad,

    Thank you for your insight.

    Is it possible to implement your suggestion for caching the landing page for caching everything on the home page of the web-site? Not sure how to define the home page URL for the Page Rules. Mydomain.com/* is capturing the whole website instead of the homepage specifically.

    Reply
    • Bhagwad Park says

      December 14, 2020 at 1:08 pm

      Remove the “*” wildcard. The asterisk means “anything else”, that’s why it’s matching the entire site.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow & Subscribe

Exclusive promos, content and more!

Most Popular Posts

NameHero’s Recommended WordPress Plugin and Theme Setup (2023)

How To Increase The InnoDB Buffer Pool Size

How To Fix A Stuck All-in-One WP Migration Import

How To Add A Subdomain In Cloudflare

How To Inline And Defer CSS On WordPress Without Plugins

Top Categories

  • WordPress
  • Website Performance
  • Web Hosting
  • Resellers
  • Website Security
  • Website Development
  • VPS Hosting
  • SEO Tips
  • Announcements
  • Domain Registration
NameHero

NameHero proudly provides web hosting to over 40,000 customers with 99.9% uptime to over 750,000 websites.

  • Master Card
  • Visa
  • American Express
  • Discover
  • Paypal
Name Hero
  • Web Hosting
  • Reseller Hosting
  • Managed Cloud
  • Domains
Help & Support
  • NameHero Blog
  • Knowledgebase
  • Announcements
  • Affiliates
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2023 NameHero, LLC. All rights reserved.

  • Privacy Policy
  • Terms of Use
  • Acceptable Use Policy
  • Payment Policy
  • DMCA