Proxy Cache

236 단어·2 분·원문(.md)

Cache-Control Cache Directives - Others

  • Cache-Control: public
    • The response can be stored in a public cache.
  • Cache-Control: private
    • The response is for a single user and must be stored in a private cache (default).
  • Cache-Control: s-maxage
    • max-age that applies only to proxy caches.
  • Age: 60 (HTTP Header)
    • The time (in seconds) the response has been in the proxy cache since it was generated by the origin server.

Cache Invalidation #

Cache-Control #

Definitive Cache Invalidation Response

  • Cache-Control: no-cache, no-store, must-revalidate
  • Pragma: no-cache
    • HTTP 1.0 backward compatibility

Cache Directive - Definitive Cache Invalidation

  • Cache-Control: no-cache
    • Data can be cached, but always validate with the origin server before using (note the name!).
  • Cache-Control: no-store
    • Data contains sensitive information, so it must not be stored. (Use in memory and delete as quickly as possible.)
  • Cache-Control: must-revalidate
    • Must validate with the origin server on the first lookup after cache expiration.
    • If origin server access fails, an error must occur - 504 (Gateway Timeout).
    • must-revalidate uses the cache if it's within the cache's valid time.
  • Pragma: no-cache
    • HTTP 1.0 backward compatibility

In no-cache, if the origin server is unreachable, the proxy can return cached data depending on the cache server's settings. Error or 200 OK (better to show old data than an error). In the case of must-revalidate, if the origin server is unreachable, an error must always occur. 504 Gateway Timeout (consider this for very important, money-related outcomes).

Back-End/http/HTTP헤더2/proxy.md