Insights:Cut TTFB to 200ms: Four Right Moves for Page Cache and CDN
A slow page load is rarely caused by heavy frontend code — more often, it's because everything gets recalculated from scratch on every request. Caching addresses exactly this problem: ensuring repeated requests don't do redundant work. The goal is clear — keeping TTFB stable under 200ms, so that subsequent above-the-fold optimizations are worthwhile.
Action 1: Distinguish Between What Can and Cannot Be Cached
- Fully cacheable pages: homepage, category pages, article detail pages, product pages — content is the same for all users;
- Not fully cacheable: admin panels, authenticated user pages, form submission results, pages carrying CSRF tokens;
- Short cache with origin revalidation: search result pages, filtered listing pages (5–60 seconds is sufficient).
Getting this wrong leads to two kinds of incidents: caching the admin panel (security issue), or setting cacheable pages to no-store (wasted performance).
Action 2: Set Cache Headers Separately by Resource Type
- Static assets with fingerprints:
Cache-Control: public, max-age=31536000, immutable - HTML pages: short
max-ageplusstale-while-revalidate, so users get the cached version while the page refreshes in the background; - API responses: set caching based on freshness needs—avoid blanket
No-cache.
Another frequent mistake is "the page was updated but visitors don't see it," usually caused by long HTML caching. Page resources should never be cached for a year.
Action Three: Let CDN Do What It Does Best
CDN's core value lies in serving static files and cached pages from nodes closest to users, cutting down network round trips. CDNs excel at handling images, CSS/JS, fonts, and cacheable HTML. They are less suited for real-time APIs or personalized content (unless edge logic is employed).
- Enable HTTPS for origin pulls and verify source certificates—never expose your origin over plain HTTP;
- Enable HTTP/3 (QUIC) to reduce connection overhead;
- Add
preconnectfor third-party domains, but don't overuse it—more than four can compete for bandwidth.
Action Four: Validate Cache Hit Rates Before Judging Results
The most common outcome after enabling caching is "configured but ineffective." The verification method is straightforward yet reliable: make two consecutive requests for the same page and check response headers such as X-Cache, Age, or CF-Cache-Status — the second request should show a hit; then confirm whether origin server access logs have actually decreased.
If the hit rate falls below 60%, it usually comes down to three causes: too many query parameters fragmenting cache keys, cookies being included in the cache key, or random numbers/timestamps mixed into the page. Eliminate each one and the hit rate will naturally improve.
One thing not to overlook: caching slows down updates
After publishing new content, remember to proactively purge the cache for that URL (most CDN backends support URL-level purging). A practical approach is to add a "purge cache" step to your publish workflow — far cheaper than waiting for users to report that the homepage still shows the old version.
Caching and CDN solve transport and redundant computation issues. For first-screen rendering problems, you'll need the actions outlined in our Core Web Vitals Optimization Guide. Only by combining both can you meet targets for TTFB and LCP together.