Inspecting Cache-Control: max-age in Browser Developer Tools
The Cache-Control: max-age directive tells the browser and caching mechanisms how long a resource should be considered fresh. Using browser developer tools, you can easily inspect and verify the behavior of the Cache-Control header for debugging or performance optimization.
For the broader Cache-Control cluster, see Cache-Control: max-age — Complete Guide, max-age for Static Assets, and max-age with public.
Open Developer Tools
- Open your browser.
- Access Developer Tools:
- Google Chrome / Microsoft Edge: Press
F12orCtrl + Shift + I(Windows/Linux), orCmd + Option + I(Mac). - Mozilla Firefox: Press
F12orCtrl + Shift + I(Windows/Linux), orCmd + Option + I(Mac). - Safari: Enable Developer Tools in Preferences > Advanced, then press
Cmd + Option + I.
- Google Chrome / Microsoft Edge: Press
Inspect Network Activity
Go to the Network Tab
In Developer Tools, click on the Network tab.
Reload the Page
- Reload the page (
F5orCtrl + R) to capture network activity. - Ensure Disable Cache (available in the Network tab) is unchecked to see cached responses.
Filter or Search for a Resource
Use the filter bar to narrow down specific resources like CSS, JS, images, or API calls.
Check Cache-Control in Response Headers
Select a Resource
Click on any resource in the Network tab to inspect its details.
View the Headers
- In the right-hand pane, click on the Headers tab.
- Look under Response Headers for the
Cache-Controlheader.
Example:
Cache-Control: max-age=3600, public
Observe Cache Behavior
- Check Status Code:
200 OK: Indicates a fresh resource served from the server or CDN.304 Not Modified: Indicates the resource was served from the cache after revalidation.
- Size: Resources served from the cache will display
(from disk cache)or(from memory cache)in the Size column.
Interpreting Cache-Control: max-age
Headers You Might See
- Cache with max-age:
- No Cache:
- No Store:
- Immutable Resource:
Cache-Control: max-age=3600, public
The resource is cacheable for 3600 seconds (1 hour).
Cache-Control: max-age=0, no-cache
The resource is cached but must be revalidated before use.
Cache-Control: no-store
The resource is not cached and must be fetched directly from the server.
Cache-Control: max-age=31536000, public, immutable
The resource is cached for 1 year and will not be revalidated during this time.
Tips for Testing Cache Behavior
- Force Reload: Perform a "hard refresh" to bypass the cache:
- Windows/Linux:
Ctrl + Shift + R. - Mac:
Cmd + Shift + R.
- Windows/Linux:
- Simulate Cache Expiry: Wait for the
max-ageduration to expire, then reload the page to observe revalidation. - Disable Cache: In the Network tab, check Disable Cache to force resources to load directly from the server.
Best Practices for Debugging Cache-Control
- Ensure Correct Headers: Use the Headers tab to verify that
Cache-Controlis set correctly. - Monitor Response Codes: Look for
304 Not Modifiedto ensure proper cache revalidation. - Test Across Browsers: Check caching behavior in multiple browsers, as implementations may vary slightly.
- Combine with Performance Tools: Use tools like Google Lighthouse or WebPageTest for caching analysis.
By leveraging browser developer tools, you can efficiently analyze and fine-tune your cache behavior for optimal performance and reliability.


