Set cache and compression rules by content type
Use long-lived caching for versioned static assets and suitable compression for text, while keeping personalized or frequently changing responses correct.
For your setup.
Choose your platform. A report may suggest one from source or delivery hints; confirm it matches the website you control.
Merge the relevant change into your existing configuration. These examples do not inspect your code or apply changes automatically. Test on a preview, then check the live response.
Review cache rules against response intent
Start with the Cache Rules already active for this zone. Scope any change to known static assets; do not cache HTML or authenticated responses by default.
Review Rules → Cache Rules → matching expression
Inspect Cache-Control and cf-cache-status on a versioned static asset and an HTML pageVerify: Test a cold and warm request, then confirm private or personalized responses remain uncacheable. Check cache status and origin headers for each route class.
Cloudflare: Cache Rules ↗Why this matters
Compression reduces transferred bytes for eligible responses; caching can avoid repeated downloads or origin trips. Both depend on response type, freshness, cache keys, and delivery configuration. A cache miss or dynamic response may be intentional.
Separate static assets from HTML
Versioned filenames let you give immutable assets a long freshness lifetime because a changed file gets a new URL. HTML often changes more frequently and may contain personalized data, so choose its cache policy based on freshness and privacy needs.
Use validators or explicit freshness
For resources that can change at a stable URL, configure appropriate `Cache-Control` freshness or validators such as ETag/Last-Modified. Verify the browser reuses, revalidates, or refreshes content as intended.
Enable compression for compressible text
Check HTML, CSS, JavaScript, and other text responses for supported Brotli or gzip delivery. Already-compressed formats such as JPEG, WebP, and WOFF2 usually gain little from another compression pass. Ensure intermediaries vary responses correctly when encoding differs.
Test the real delivery path
Inspect status, Content-Encoding, Cache-Control, Age, ETag, and cache status from a visitor request. A header is an observation, not proof that all visitors receive the same cached response.
For your setup
Cloudflare
Cloudflare applies default cache and compression behavior based on content type and rules. Use Cache Rules and Compression Rules only after reviewing origin headers, dynamic content, cookies, and the desired freshness behavior.
Next.js
Hashed build assets can be cached separately from route HTML. Confirm the deployed platform’s actual headers; framework defaults may be changed by a CDN, Worker, or hosting layer.
WordPress
Page caching can be unsafe for logged-in, cart, account, or otherwise personalized responses. Use the cache plugin or host’s supported exclusions and test those states before broadening cache rules.
Check your work
- Request the same static asset twice and inspect cache behavior.
- Change a versioned asset and confirm the new URL is served.
- Test anonymous and authenticated/personalized pages separately.
- Confirm text responses negotiate compression and compressed images/fonts are not needlessly recompressed.