freecoding.school100% FREE · NO SIGNUP
Gateway RidgeISSUE #6 of 35

caching · vary · cache-control · expires

Gateway GusVSTimeout Titan
Gateway Gus saysCache-Control directives tell clients and proxies how long and how to cache.

Cache-Control is the master switch: max-age=300 (cache 5 min), no-cache (revalidate before use), no-store (never cache — for sensitive data), private (browser only, not shared proxies), public (anyone). Vary tells caches which request headers affect the response (e.g. Vary: Accept-Encoding). Get these right and you cut load dramatically.

Power-ups you unlock

Timeout Titan attacks — common mistakes

Boss battleChoose Cache-Control for: a public logo, and a user’s account page.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>logo:    Cache-Control: public, max-age=86400
account: Cache-Control: private, no-store</pre></body></html>
▶ Open the interactive comic issue
‹ Caching · Etag · Last-ModifiedCdn Caching · Edge Caches ›