Overview

During major promotions (such as Double 11 or Black Friday), traffic surges. If cdn nodes have not cached content in advance, a sudden flood of back-to-origin requests may overload or even crash the origin server. Preheating and refreshing are two important CDN features, and using them correctly can greatly improve stability during major promotions.

This article introduces the differences between preheating and refreshing, their use cases, and specific operation steps.

I. Preheating vs Refresh

Preload: Actively pushes content to CDN edge nodes so that when users visit for the first time, the content is returned directly from node cache without going back to the origin. Preheating is suitable for loading popular pages and resources in advance before major promotions.

Purge: Clears expired content from CDN nodes and forces back-to-origin retrieval of the latest version. Purging is suitable for updating product prices, fixing incorrect content, and cleaning sensitive information.

II. Best Practices for Preheating

1. Preload promotional landing pages 1–2 days in advance
The HTML of the main promotion venue, flash sale pages, and best-selling product pages needs to be preloaded in advance. This avoids a large number of users penetrating back to the origin when the event starts.

2. Preload static resources
Images, CSS, JS, and font files should also be preloaded. It is recommended to use the CDN console's batch preload feature or write a script to call the API for preloading.

3. Preload nodes in popular regions
If you know the main source of traffic (such as first-tier cities), you can specify preloading to nodes in the corresponding regions to reduce cross-region scheduling latency.

4. Preload frequency
Preloading is not a one-time task. Preload static resources one week before the promotion, and preload dynamic pages 24 hours before. Preload tasks usually have quota limits, so plan ahead.

III. Best Practices for Refresh

1. Refresh on demand
Do not refresh the entire site, otherwise all nodes will go back to the origin, causing enormous instantaneous pressure. Only refresh changed pages or resources.

2. Batch refresh
Use wildcard refreshes for directories, for example refreshing all pages under /product/*. Note that some CDNs do not support wildcards or have restrictions.

3. Scheduled refresh
For price-related pages, you can set a shorter cache time (such as 5 minutes) instead of manually refreshing.

4. Verify after refresh
After refreshing, use the curl -I command to check the response header (X-Cache: MISS) to confirm that the cache has been cleared.

IV. Operation Examples for Upyun/Qiniu Cloud/Cloudflare

Upyun: Console "CDN Service" → select domain → "Cache Management". Supports URL preload, directory preload, URL refresh, and directory refresh. APIs: /purge/ and /prefetch/.

Qiniu Cloud: Console "Fusion CDN" → "Refresh & Preload". Supports URL preload (limited to 100 entries/day). Refresh supports URLs and directories.

Cloudflare: The free plan does not support preheating, only refresh. API method: curl -X POST "https://api.cloudflare.com/client/v4/zones/{zone_id}/purge_cache". Supports single URL refresh and full site refresh.

V. Quotas and Costs for Preheating and Refresh

Most CDN providers have quantity limits on preheating and refresh. Upyun: refresh is free but has frequency limits; preheating is billed per request (resource packages can be purchased). Qiniu Cloud: refresh is free, and preheating is also free but has a quota. Cloudflare: refresh is free, and preheating requires an Enterprise plan.

Purchase preheating packages in advance before major promotions to avoid insufficient quotas during the event.

VI. Monitoring and Alerts

Set up CDN back-to-origin traffic alerts. If back-to-origin traffic suddenly spikes after the promotion starts, it indicates a high cache miss rate, possibly because preheating was unsuccessful or there are cache rule issues. Analyze hit rate through CDN logs (refer to previous articles).

Combine with origin server monitoring (CPU, bandwidth) to avoid back-to-origin penetration crashing the server.

Correct use of preheating and refresh can ensure stable website operation during major promotions and improve user experience.