QA
Intermediate LevelSystem Design & Architecture

How do Cache-Control directives and Surrogate Keys (Cache-Tags) control CDN purging?

❓ Interview Prompt: Explain `Cache-Control` directives (`public`, `s-maxage`, `stale-while-revalidate`), and `Surrogate-Key` / `Cache-Tag` CDN cache purging.

HTTP response headers govern CDN edge caching behavior:

Directives & Cache-Tags:

β€’
's-maxage=3600': Instructs CDN edge proxies to cache the response for 1 hour.
β€’
'stale-while-revalidate=60': Serves stale content from CDN cache while fetching a fresh copy asynchronously in the background.
β€’
'Surrogate-Key / Cache-Tag': Assigns tag identifiers to cached pages ('Cache-Tag: product-100'), allowing instant targeted CDN cache purging of thousands of pages with a single API call!

Code Implementation Example

http
HTTP/1.1 200 OK
Cache-Control: public, s-maxage=86400, stale-while-revalidate=300
Cache-Tag: category-electronics, brand-sony
πŸ’‘CDN Cache-Control and Cache-Tag HTTP response headers.
🎯 Interview Key Takeaway

Use Surrogate-Key / Cache-Tag headers to execute instant targeted CDN cache invalidation across related pages.

#System Design#CDN#Cache-Control#Cache-Tag#Intermediate
Back to all System Design & Architecture Questions→

More System Design & Architecture Interview Questions

Beginner LevelSystem Design & Architecture

Explain the CAP Theorem and PACELC Theorem with real-world database examples.

Beginner LevelSystem Design & Architecture

What is Vertical Scaling (Scale Up) vs Horizontal Scaling (Scale Out)?

Beginner LevelSystem Design & Architecture

How do Load Balancers distribute traffic (Round Robin, Least Connections, IP Hash)?