# ---------------------------------------------------------------------- # | Cache Control | # ---------------------------------------------------------------------- # Serve resources with appropriate cache control directives. # # The `Cache-Control` header field holds directives (instructions) that control # caching in browsers and shared caches (e.g. Proxies, CDNs). # Its use targets web performances improvement by specifying the expected # client and network caches behaviors. # # The usable cache directives are listed here: # https://www.iana.org/assignments/http-cache-directives/http-cache-directives.xml # # The cache directives are documented here: # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#response_directives # # (!) Enable and configure this configuration with care. # Default values should embrace conformance for static files and simple # apps, but cache control definition at backend level is highly preferred. # Incorrect directives can lead to data leaks, or can degrade performances. # # More specifically, in-depth understanding on `public` vs `private` # directives meanings is highly recommended. A resource with `public` will # be cached by shared caches like CDN, even if a user session is active. # # (*) To avoid duplication of the directive `no-cache` on `Cache-Control`, # the value is skipped here. # The directive `no-cache` is already defined by Nginx `expires` when set # to `epoch`. This ensure a correct value enforcement whenever cache # control configuration is used or not. # Cache expiration configuration `expires` is described in the file # h5bp/web_performance/cache_expiration.conf. # https://nginx.org/en/docs/http/ngx_http_headers_module.html#expires # # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control # https://www.rfc-editor.org/rfc/rfc9111.html # https://www.rfc-editor.org/rfc/rfc8246.html # https://www.rfc-editor.org/rfc/rfc5861.html # https://www.iana.org/assignments/http-cache-directives/http-cache-directives.xml # https://cache-tests.fyi/ add_header Cache-Control $cache_control;