CDN Edge Caching and Content Preheating: Make Every First Visit a Cache Hit
Create Time:2026-06-26 14:33:32
浏览量
1015

CDN Edge Caching and Content Preheating: Make Every First Visit a Cache Hit

微信图片_2026-06-26_143121_997.png

Before last year's Singles' Day sale, an e-commerce client asked me: "Traffic spikes on sale day. When users visit a product page for the first time, will the CDN already have it cached? Or will everything go back to my origin and crash it?"

I asked: "Have you preheated your content?"

They replied: "What's preheating?"

This is the most overlooked part of CDN usage: CDN caching is passive by default. Nobody visits, nobody caches. On sale day, the first wave of visitors all go back to the origin.

01 What Is Edge Caching?

Edge caching is the practice of pre‑loading content onto CDN edge nodes closest to your users, ready for the very first request. While a CDN's primary role is to serve cached content from edge servers near users to reduce latency, the "default" mode is often pull CDN – passive caching.

Pull CDN (passive): Content is only cached when a user requests it. The first visitor always triggers a fetch from the origin. Subsequent visitors in the same region get the cached copy.

Push CDN (active): Content is proactively uploaded to the edge nodes before any user asks for it. The first visitor gets a cache hit.

That e‑commerce client needed push CDN – to push product images and campaign pages to edge nodes before the sale, so the first user would already hit a cache.

02 Why Are First Visits Slow?

CDN caching is passive by default. Before a file can be served from the edge, someone must request it first.

The first-visit path: User requests → CDN node → Miss (no cache) → Request goes to origin → Content fetched and returned → Optionally cached at edge for future requests.

The cold start problem: New campaign pages, new product images – the CDN edge nodes have never seen them. On launch, the first wave of users all miss the cache, triggering a "back‑to‑origin storm" that can overwhelm the origin.

03 Preheating Solves the First‑Visit Problem

Preheating proactively pulls content to edge nodes before users ask for it.

How it works: You submit a list of URLs (individual files, directories, or patterns) to the CDN. The system pulls fresh content from your origin and distributes it to the edge nodes.

When to preheat:

  • Before major events or flash sales

  • Before a new product launch

  • After a purge – always preheat after purging to ensure fresh content is cached immediately

Note: Preheating takes time. More files and more edge nodes means more time. Don't start 5 minutes before a flash sale.

04 Preheating vs. Purging – Two Operations, One Workflow

Preheating and purging are often confused. They're complementary and should be used in the right order.

Purge (refresh): Deletes cached content from edge nodes. Forces the CDN to fetch fresh content on the next request. Use when your content has changed.

Preheat: Pushes content to edge nodes after a purge, so users immediately get the latest version.

Critical rule: For updated content, purge first, then preheat. If you preheat before purging, you're just pushing old content back to the edge. That's doing nothing.

05 Other Ways to Improve First‑Visit Hit Rate

Set cache TTL appropriately: Static resources (images, CSS, JS) benefit from long TTLs (e.g., 1 year). Dynamic or frequently updated content should use short TTLs or no caching at all.

Ignore query string parameters: When URLs include timestamp or random parameters like ?t=123456, CDNs treat each as a different file. Enabling "ignore query string" can drastically improve hit rate.

Use versioning: Instead of purging, use file versioning (style.v2.css) – the new URL triggers a new cache without wiping old entries.

06 A Real Story: Preheated for the Sale

That e‑commerce client preheated all campaign pages and hot product images 6 hours before the sale. When the sale started, CDN edge nodes already had everything cached. The origin stayed stable through the entire peak period.

Their ops lead later said: "We used to only worry about scaling servers before big sales. Now we preheat the CDN first – it's a game changer."

Preheating should be on your checklist before every major event.