Skip to content
EncryptTechBD
Home Industries Our Work Blog Pricing About Contact Discuss Your Project
বাংলা (BN)
Website & Infrastructure 5 min read

CDN caching strategy checklist

A content-class checklist for cache headers, keys, purge rules and edge security, written for teams that cannot afford a cache poisoning incident.

E
EncryptTechBD · 0 comments
Open laptop glowing in a dimly lit room
Photo: Jay Wennington / StockSnap

A CDN does not make a website fast by itself. It brings content you have already optimised closer to the visitor. If the origin sends vague cache headers, forwards every cookie and purges everything on each deploy, the CDN becomes an expensive proxy rather than a performance layer.

This checklist is organised by content class, because the right policy for a product image is wrong for an account page. Each item names the evidence to keep and the person who should own it. It is written for the manager who signs off on the site and the developer who configures the edge.

1. Map content before touching settings

  • Immutable assets. Versioned CSS, JavaScript, fonts and images that never change at the same URL.
  • Public HTML. Home, category, product and article pages that are the same for most visitors.
  • Personalised HTML. Account, cart, checkout and order pages.
  • APIs. Public catalogue endpoints, authenticated customer endpoints, and payment or webhook endpoints.
  • Media and downloads. Large images, PDFs, video segments and software packages.

Evidence: a one-page content map with the cache policy and owner for each class. Without it, every debate becomes a guess.

2. Set headers that match the class

  • Immutable assets: Cache-Control: public, max-age=31536000, immutable with a content hash in the filename.
  • Public HTML: a short shared-cache lifetime plus revalidation, for example s-maxage with stale-while-revalidate, and an ETag.
  • Personalised pages: Cache-Control: private, no-store where the page contains account or payment data.
  • Public APIs: explicit s-maxage and stale-if-error only when stale data is safe to serve.
  • Authenticated APIs: private, no-store and no shared caching, without exceptions.

Evidence: response header captures for one URL in each class. Owner: application lead.

3. Design the cache key deliberately

  • Decide which query parameters matter. Pagination and filters usually do; marketing parameters such as utm_* usually do not.
  • Normalise parameter order and casing so the same page does not create several cache entries.
  • Include language, currency and device variant only where the response actually differs.
  • Avoid Vary: Cookie on public pages. It fragments the cache and hides a personalisation problem rather than solving it.
  • Use Vary: Accept-Encoding for compressed responses, and keep the list short.

Evidence: a documented key scheme and a test showing that two equivalent URLs return the same cached object.

4. Keep private data out of shared caches

  • Never cache a response that sets a session cookie or contains a CSRF token.
  • Strip or separate authenticated traffic at the edge rather than relying on the origin to remember.
  • Check that error pages do not echo request headers, tokens or stack traces.
  • Set a short negative-cache lifetime for 404s, and no caching for 500s unless the error page is static and safe.
  • Review the cache key for host header poisoning and unvalidated forwarding headers.

Evidence: a test account logged in from two browsers, confirming that neither sees the other's data. Owner: security lead.

5. Make purge and deployment predictable

  • Fingerprint assets at build time so a deploy creates new URLs instead of overwriting old ones.
  • Use tag-based or surrogate-key purge for content changes, not a blanket purge.
  • Reserve purge-all for emergencies, and log who triggered it.
  • Warm the cache after a deploy for the top landing pages, but do not hide origin errors by pre-warming everything.
  • Keep a rollback path that does not depend on the CDN dashboard being available.

Evidence: a deploy runbook showing the purge step, the approval, and the rollback step.

6. Configure the edge for failure

  • Set origin timeouts and retry limits that match the application's real capacity.
  • Use an origin shield or a mid-tier cache if the origin is fragile or far from the edge.
  • Serve a static maintenance or error page from the edge when the origin is unavailable.
  • Bypass caching for websockets, streaming and payment callbacks unless you have tested the behaviour.
  • Compress text responses and resize images at the edge only if the transformation is deterministic and cacheable.

7. Measure the cache, not just the CDN

  • Hit ratio by content class, not one blended number.
  • Origin requests per minute and origin response time.
  • Time to first byte for cached and uncached requests.
  • 5xx rate at the edge and at the origin.
  • Purge volume and the reason for each purge.

Rollout sequence

  1. Audit headers on production and record the current hit ratio.
  2. Fix the content map and the private-content rules first.
  3. Apply long-lived caching to fingerprinted assets only.
  4. Test HTML and API policies in staging with production-like traffic.
  5. Canary one route or one market, watch errors and origin load, then widen.
  6. Document the policy and add a header check to the release checklist.

Keep the policy in the repository next to the application configuration. A cache rule that exists only in a dashboard is lost at the next migration, and the next team will rediscover the same mistakes under pressure.

Common mistakes

  • Caching HTML that contains a customer name or cart count.
  • Purging the whole zone on every deploy because asset URLs are not versioned.
  • Forwarding all cookies to the origin and calling the result "personalisation".
  • Ignoring query strings, then wondering why filters show the wrong products.
  • Setting a long TTL on a page that changes hourly.
  • Treating a high hit ratio as success when the cached object is stale or wrong.

Where this fits in our work

Cache policy is part of website and infrastructure engineering, not a plugin setting. Our Managed Technology & Cybersecurity division reviews the origin, CDN and security configuration together; the pricing page explains how the work is scoped. For the maintenance side, read website maintenance services compared.

Sources

Services that deliver this

Want this implemented properly?

Pricing →

Every engagement starts with a written scope. If a requirement is outside it, we quote it separately before starting.

Responses (0)

No comments yet. Add the first one below.

Leave a response

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

Keep reading

More field notes