intermediate

Browser caching

Combine HTTP cache, Cache Storage, immutable assets, validation, invalidation, and offline strategy deliberately.

Browser caching includes the HTTP cache, memory cache, disk cache, Cache Storage, and application-level data caches. Strong answers combine immutable hashed assets, validation for mutable resources, explicit invalidation, and service-worker strategies only where offline or resilience behavior is wanted.

					Cache-Control: public, max-age=31536000, immutable
# hashed build assets

Cache-Control: no-cache
# revalidate with ETag on each use
				

Never mark HTML shell as long-lived immutable unless you have a rigorous deployment invalidation story. Separate public CDN assets from private API responses.

On interviews: trade-offs about cache-control, ETags, stale content, CDN interaction, and authenticated responses.

Common pitfalls: caching HTML as immutable can trap old deployments. Caching private data without varying or invalidation can leak information.

The trade-off is convenience versus control — pick the mechanism that matches your coupling and performance budget.

Checklist:

  • Hash and immutable static assets.
  • Revalidate mutable API data.
  • Plan invalidation on deploy and logout.
  • Keep private responses out of shared caches.