• 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

How To Achieve ~90% Cache Hit Ratio On Cloudflare

Bhagwad Park

Published on: March 31, 2021

Categories: Website Performance 0

Let me start this with a screenshot of my Cloudflare dashboard showing the cache hit ratio:

Cache Hit Ratio on Cloudflare
Cache Hit Ratio on Cloudflare

I’m caching 85% of all the requests to my site WP-Tweaks. Keep in mind this includes not just legitimate traffic, but also bot traffic, spam, and even hacking attempts. The good news is that you can achieve this too. And not just with Cloudflare. NameHero allows free integration with QUIC.cloud, which can get you close to the percentage displayed above. However, QUIC.cloud is still technically in beta and doesn’t have nearly as many features as Cloudflare. So for this article, I’ll be talking about how to achieve a high cache hit ratio with Cloudflare only.

What is a Cache Hit Ratio?

The cache hit ratio is the percentage of requests that are served by the EDGE server instead of your origin. The higher this number is, the less strain on your site, and the faster your visitors see your content. This is made most clear by the reduction in the TTFB (Time To First Byte) metric. And this metric directly impacts the Core Web Vital metrics like LCP (Largest Contentful Paint).

The EDGE servers are almost always located closer to your visitors than your origin server. And the content is cached, which means it doesn’t have to be generated from scratch. Both of these combine to give blazing fast page download speeds.

This Includes Dynamic Content like HTML!

For years, CDNs only cached static content like JavaScript and CSS. Even today, Cloudflare will only cache static content by default. But thanks to the techniques I show below, you can get it to cache dynamic HTML content as well. This dramatically improves your cache hit ratio – particularly for bots, which don’t need to download static content.

So how do we reach this super high hit percentage?

Step 1. Configuring Dynamic Content Caching

With Cloudflare, I’ve written a tutorial on how to cache dynamic content. There’s also a Cloudflare free feature for “Pro” plans and above that uses the Cloudflare plugin on your WordPress installation for HTML caching. It’s called “APO”.

For NameHero users, you can check out our knowledgebase on how to enable QUIC.cloud (Step 6). Once you have this going, you’ll immediately see a big spike in your cache hit ratio. All the bots (good and bad) will be served static HTML pages instead of getting responses from your origin. It works great!

Step 2: Enable a Good Cloud Firewall

I routinely block hundreds or even thousands of bad hits on my site using the Cloudflare WAF (Web Application Firewall). Bots probing for weaknesses should never even receive a response from your site – let alone make it through to your origin server. For Cloudflare, the WAF comes with the “Pro” plan. I prefer a cloud-based firewall to something like WordPress that runs on your server because it reduces the load on your server.

Step 3: Use Page Rules for Popular Redirects

If you’re an affiliate site, you probably have some really popular URLs that are redirected to your real affiliate link. I suggest you use Cloudflare’s Page Rules for these redirects. Not only do they keep the workload off your server, but your paying customers will also get to the destination landing page much faster. Win-win for everyone!

Step 4: Implement Sensible Rate Limiting Rules

Rate limiting is very difficult to set up correctly. But one area where you can use them safely is on your login page, where there aren’t expected to be dozens of requests every minute. I also use them on my affiliate URLs where I don’t expect an IP to be clicking many URLs in a spammy way.

Rate limiting rules have the potential to really save your site one day if it comes under heavy attack. So use them wisely!

Summary

Implementing all these techniques should easily get you in the range of 90% for your cache hit ratio. Once that happens, you’ll see all kinds of good things happen for your site. Visitors will be happier, and you’ll have fewer people accessing your site maliciously. What’s not to like?

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

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