HTTP cache


Revisiting a web page can speed up user access and save traffic.

Caching strategies

The HTTP cache-Control header defines the Cache policy, under what conditions responses can be cached, and for how long.

A header (such as Expires) defined in the HTTP/1.1 specification that replaces a previous header (such as Expires) used to define caching policies.

Cache conditions

no store

Do not cache

no cache

Every time you use the cache, go to the server to verify that the resource is up to date.

Where can I cache it


The default


Only cached on the user’s browser, not on the public cache

How long


If the cache is used to request resources, the cache must be obtained from the server

Is it the latest

If it is the latest, continue to use the cache, otherwise request from the server. The cached available information is placed in HTTP Response headers


The expiration date is marked.


If the client and server time is inconsistent, the updated file information may be incorrect.

HTTP / 1.0


When the resource was last updated. Accurate to the second. When the client requests the resource again, it places this value in the request header if-modified-since to determine If it is updated.

HTTP / 1.0


If updates occur within seconds, there is an error.


Returns a string identifier that changes based on the contents of the file. After the browser accepts the request header, the next request is sent as if-none-match. If the eTag value does not change, caching is used. The priority is the highest.


The server gets the latest results

Back to 200

Resources read directly from the local cache

Back to 200

Use the cache after checking with the server

Back to 304

Storage location

The browser determines whether it is stored in memory cache or disk cache, depending on the brand.

How to configure

On the server, see…


Google Document HTTP cache

Additional reading



Pay attention to

For non-static resources, such as JSON (/user/: ID) to retrieve user information, the browser may ignore the cache.

This article is formatted using MDNICE