Course contentsShow
← Web Development
Lesson 2207 of 2,98240. Browser DevTools Deep DiveFree lesson

Cache Behavior and Validation

Verify if resources are served from cache, understand cache-control headers, and test cache invalidation.

Cache Behavior and Validation

You'll learn how to use DevTools to verify whether resources are actually being served from cache and how to confirm your cache configuration is working as intended.

What This Means

After configuring cache headers in previous lessons, you need to prove your caching strategy is working. Browser DevTools let you inspect each network request to see if it was served from disk cache, memory cache, or fetched fresh from the server. You can also verify that validation mechanisms (ETag, Last-Modified) are functioning correctly when checking for updated resources.

Inspecting Cache Status

In the Network panel, the Size column reveals cache behavior:

  • "disk cache" or "memory cache" = resource served locally (no network request)
  • Actual size (e.g., "45 KB") = downloaded from server
  • "(from ServiceWorker)" = served by your service worker

The Status column shows 304 Not Modified when validation succeeds—the browser asked "has this changed?" and the server said "no, use your cached copy."

Verifying Cache Headers

Click any resource to inspect its Response Headers. Look for:

  • Cache-Control: max-age=31536000, immutable (your directives)
  • ETag: "abc123" or Last-Modified: Wed, 21 Oct 2022... (validation tokens)

In subsequent requests, check the Request Headers for If-None-Match or If-Modified-Since—these prove the browser is validating cached resources.

Testing Cache Invalidation

Hard-refresh (Ctrl/Cmd+Shift+R) or "Disable cache" checkbox forces fresh downloads, letting you test whether cache-busting strategies (like versioned filenames) work when you deploy updates.

Key Takeaway:
DevTools Network panel shows exactly where each resource came from—cache or network—and confirms your Cache-Control headers and validation tokens are working as designed.