Cache-Control parameters

  network

Cache-Control has many parameters to choose from, which are very important for cache control. Parameters include:

  • Public: Responses are cached and can be shared among multiple users.

  • Private: The response can only be used as a private cache. For example, in a browser, it cannot be shared among users, so it cannot be cached by the reverse proxy after setting this parameter.

  • No-cache: Response will not be cached, but resources will be requested from the server in real time, which enables HTTP authentication to prohibit caching to ensure security. In fact, this is easy to be misunderstood. Literally, the response is not cached. In fact, the response will be cached in the case of no-cache, but the client has to evaluate the validity of the cached response to the server every time.

  • No-store: Under any conditions, responses will not be cached and will not be written to the client’s disk. This is also used for some sensitive responses based on security considerations.

  • MAX-AGE = [Unit: Seconds]: Set the maximum effective time of the cache, starting from the time returned by the server.

  • S-MAXAGE = [Unit: Seconds]: Similar to max-age, but it is only used for shared caches, such as proxies.