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

Jonathan Dingman

Dad, Product Guy, WordPress, SEO, and TailwindCSS.

  • SEO
  • Google
  • Google Sheets
  • WordPress
  • About Jonathan

Jonathan DOT VC » Tech » 100% Free & Simple Full Site Caching at the Edge with Cloudflare

100% Free & Simple Full Site Caching at the Edge with Cloudflare

July 24, 2024 by Jonathan Dingman Leave a Comment

I recently started playing around with some of the configuration settings in Cloudflare and I realized something that I could cache the entire site for free at the edge. It’s very simple. Let’s take a look at the configuration settings there are only two caching rules that you need to configure.

This works entirely on the free plan, no costs involved. You don’t even need to put a credit card in your account.

First Rule: Bypass Cache on Cookie

Step 1: Create a rule to bypass all caching when the cookie is present

Create a rule with the following conditions:

  • Field = Cookie
  • Operator = contains
  • Value = wordpress_logged_in

This will check if the request being made is in association with a cookie that has the name wordpress_logged_in_ in it.

WordPress’ developer documentation states that WordPress will set a cookie value of wordpress_logged_in_[hash] which can be quite useful for this purpose.

Cloudflare’s caching rules configuration allows us to trigger based on this.

Create a rule to bypass all caching when the cookie is present

Step 2: Create a second rule…to cache when the cookie is not present.

Note that it’s critical that you have this as the second rule, because the first rule will trigger if you’re logged in. If you’re not logged, it will skip the first rule and go to the second rule — this one, that we’re about to create.

Create a rule that is the reversed of the first rule. When the cookie is not present, serve up a cached page.

Create a second rule...to cache when the cookie is not present.

Next, you need to configure the level of caching you want when this rule is triggered, which will be for all logged-out users.

Below are the settings I use. Enable this rule to be eligible for caching.

Next, enable caching at the Edge.

Enable caching at the Edge

Assuming you have content that is not changing, you can set a Browser Cache TTL as well.

Add browsing caching to assets

Once you have added both rules, confirm that they are in the correct order.

Step 3: Profit!

PROFIT!

Related Posts:

  • openx-logo
    OpenX Advanced Targeting Using WordPress
  • accordion-mockup
    How Accordion UX Impacts SEO: Pros, Cons, and Best Practices
  • product-requirements-document
    The Ultimate Guide to Crafting a Powerful Product…
  • argetina-waterfalls-rainbow
    How to Setup a VAST/VPAID Waterfall with VideoJS

Filed Under: Tech Tagged With: Cloudflare, Performance, User Experience, WordPress

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

Jonathan "Jon" Dingman

Welcome to my little corner of the interwebz!

My name is Jonathan.

Recent Posts

  • [Humor] Giving Excel a September 10th rating.
  • Mastering Alphabetization in Google Sheets: A Step-by-Step Guide
  • 100% Free & Simple Full Site Caching at the Edge with Cloudflare
  • Leveraging Structured Data Schema.org Markup for Paginated eCommerce Category Pages
  • How Accordion UX Impacts SEO: Pros, Cons, and Best Practices
  • How to Create a Dropdown List in Google Sheets
  • Sparklines: The Pocket-Sized Warriors of Google Sheets for Quick Data Insights
  • Google Sheets and Data Analysis: Interpreting Zeroes
  • The Ultimate Guide to Dynamic Drop-Down Lists in Google Sheets
  • Google Sheets Best Practices: Perfecting Data Entry with Advanced Validation Techniques
  • Coloring By Numbers in Google Sheets: Making Zeros Disappear
  • 12 Easy to use Features of Google Analytics
  • Self-hosting WordPress: Looking at WordOps vs SlickStack
  • How I Setup a WordPress Cron Job Using AWS Lambda
  • Using Cloudflare, an Amazon Load Balancer, with Nginx and Fail2Ban
  • How to Automate WordPress Backups to Amazon S3 with a Bash Script
  • How to Track Light/Dark Mode in Google Analytics through Google Tag Manager
  • How to Track Ad Block Usage in Google Analytics through Google Tag Manager
  • How to Setup a VAST/VPAID Waterfall with VideoJS
  • How to Return an Empty Cell When the Value is Zero in Google Sheets

Friends

  • Dre is awesome
  • Rareform – Best Upcycled and Recycles Bags

Powered by DigitalOcean
Copyright © 2025

  • Sitemap
  • Privacy
  • Terms