2022-11-03 02:34:32 +01:00
|
|
|
# ----------------------------------------------------------------------
|
2022-11-03 02:44:02 +01:00
|
|
|
# | Cache Control |
|
2022-11-03 02:34:32 +01:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
2022-12-05 14:20:39 +01:00
|
|
|
# Serve resources with appropriate cache control directives.
|
2022-11-03 02:34:32 +01:00
|
|
|
#
|
2022-11-03 23:50:13 +01:00
|
|
|
# The `Cache-Control` header field holds directives (instructions) that control
|
|
|
|
# caching in browsers and shared caches (e.g. Proxies, CDNs).
|
2022-12-05 14:20:39 +01:00
|
|
|
# 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.
|
|
|
|
#
|
2022-12-05 20:07:01 +01:00
|
|
|
# (*) 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.
|
2022-12-05 20:39:44 +01:00
|
|
|
# https://nginx.org/en/docs/http/ngx_http_headers_module.html#expires
|
2022-11-03 02:44:02 +01:00
|
|
|
#
|
2022-11-03 02:34:32 +01:00
|
|
|
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
|
2022-11-03 23:50:13 +01:00
|
|
|
# https://www.rfc-editor.org/rfc/rfc9111.html
|
|
|
|
# https://www.rfc-editor.org/rfc/rfc8246.html
|
2022-12-05 14:20:39 +01:00
|
|
|
# https://www.rfc-editor.org/rfc/rfc5861.html
|
2022-11-03 23:50:13 +01:00
|
|
|
# https://www.iana.org/assignments/http-cache-directives/http-cache-directives.xml
|
|
|
|
# https://cache-tests.fyi/
|
2022-11-03 02:34:32 +01:00
|
|
|
|
|
|
|
add_header Cache-Control $cache_control;
|