Design the delivery policy for a public inspection guide, its English and Hindi routes, a private case dashboard, a versioned application bundle, and a primary case photograph. The public guide can be cached for a bounded period if an editorial correction can be invalidated across every locale and edge. Its compressed representation must match the client's advertised capability. The private dashboard must never be reused by a shared cache for another account, even when both viewers request the same path. Versioned bundles may live longer because a changed build gets a new URL. The primary photograph must be discoverable early on the route where it appears; offscreen thumbnails should not receive the same priority. Show real response headers, body revisions, and waterfall measurements in the project review.
Project: edge cache and critical resource release
Build contract
- Classify every response by audience, cache lifetime, representation variants, and invalidation owner before setting edge rules.
- Test two accounts and two locales through a warm shared cache, including a 304 response and different encoding capabilities.
- Publish guide revision 47, purge all affected variants, and inspect two edge locations before claiming the correction is complete.
- Compare cold and warm waterfalls for one primary image plus 18 thumbnails, checking transfer, largest-content timing, and duplicate downloads.
Implementation checkpoint
function mayUseSharedCache(response) {
return response.publicContent && !response.accountSpecific && response.variantKeyComplete;
}
console.log(mayUseSharedCache({ publicContent: false, accountSpecific: true, variantKeyComplete: true }));
// Output: falseCost and boundaries
A public cache lowers repeated origin work, but every language and content-encoding variant consumes storage and can reduce the hit rate. A purge across e edge locations creates at least O(e) distribution work and may not finish simultaneously. Compressing a b-byte text response costs CPU proportional to its size, while an already-compressed photo may yield little transfer saving. Each unnecessary preloaded image consumes bytes and competes with the current page's critical request. Report hit rate alongside correctness, purge delay, origin load, encoded size, and primary-image request start time; none of those numbers alone proves a good release.
Failure drill
Warm the dashboard cache as account 29 and request the same path as account 62. Any copied case count is a policy failure, even if a later client fetch repairs it. Warm the guide in one language and encoding, then request another; a wrong-language page or undecodable bytes exposes an incomplete variant key. Publish a guide correction but purge only one locale, leaving an old checklist elsewhere. Finally mark all images high priority and compare the waterfall with a single primary-image hint. If the primary image URL appears only after JavaScript, move discovery into initial HTML before tuning priority.
Acceptance checks
- No warm shared-cache request leaks a private dashboard across accounts.
- Locales and encodings remain correct through cache hits and validation responses.
- Every public guide variant reaches the intended revision after an observable purge.
- The primary image starts early without turning offscreen thumbnails into competing critical requests.
Common Mistakes
- Using a cookie variant as the only protection for private HTML.
- Calling one edge purge globally complete without verification.
- Compressing a response without matching metadata and Vary.
- Giving all images high priority instead of measuring the first visible candidate.
Related lessons
Shared Cache Keys and Private Response Boundaries; Stale Revalidation and Versioned Purges; Content Negotiation and Compression Contracts; Critical Resource Discovery and Priority; HTTP caching: validate a changed representation with an ETag.
