DEV Community


Two lesser-known Cache-Control directives that you may find useful

Šime Vidas
・1 min read

When it comes to the HTTP Cache-Control response header, I try to follow Jake Archibald’s advice, which revolves around two main patterns: (1) using a long max-age (e.g., 1 year) for content that never changes (and whose URL is versioned), and (2) using no-cache for content that can change (the browser will always check with the server if a newer version is available before using the cached content).

In addition to max-age and no-cache, there are a few other Cache-Control directives that can be useful in some scenarios.

  • The no-store directive instructs the browser to not store the response in the cache at all. This can be useful for responses that contain sensitive or time-critical information.

    Cache-Control: no-store

  • The immutable directive tells the browser that the response will not change over time, which effectively means that the browser never has to check with the server if a newer version is available.

    Cache-Control: max-age=31536000, immutable

    When the user manually refreshes the page, the browser checks with the server even if the cached content is still “fresh.” In this situation, immutable can help prevent unnecessary checks for content that never changes.

See Harry Roberts’s article “Cache-Control for Civilians” for more details on the different Cache-Control directives.

This content was originally published on

Discussion (0)