server-configs-nginx/h5bp/web_performance/cache_expiration.conf

64 lines
2.2 KiB
Nginx Configuration File
Raw Normal View History

# ----------------------------------------------------------------------
# | Cache expiration |
# ----------------------------------------------------------------------
2020-04-14 11:53:56 +02:00
# Serve resources with a far-future expiration date.
#
# (!) If you don't control versioning with filename-based cache busting, you
2022-11-03 02:30:40 +01:00
# should consider lowering the cache times to something like one week.
#
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expires
# https://nginx.org/en/docs/http/ngx_http_headers_module.html#expires
map $sent_http_content_type $expires {
2022-12-04 23:36:10 +01:00
# Default: Fallback
2021-11-14 22:18:27 +01:00
default 1y;
2022-12-04 23:36:10 +01:00
# Default: No content
"" off;
2022-12-04 23:36:10 +01:00
# Specific: Assets
~*image/svg\+xml 1y;
~*image/vnd.microsoft.icon 1w;
~*image/x-icon 1w;
2022-12-04 23:36:10 +01:00
# Specific: Manifests
~*application/manifest\+json 1w;
2022-10-28 10:44:28 +02:00
~*text/cache-manifest epoch;
2022-12-04 23:36:10 +01:00
# Specific: Data interchange
~*application/atom\+xml 1h;
~*application/rdf\+xml 1h;
~*application/rss\+xml 1h;
# Specific: Documents
~*text/html epoch;
2022-10-28 10:44:28 +02:00
~*text/markdown epoch;
2022-12-04 23:36:10 +01:00
~*text/calendar epoch;
# Specific: Other
~*text/x-cross-domain-policy 1w;
2022-12-04 23:36:10 +01:00
# Generic: Data
~*json epoch;
~*xml epoch;
2022-12-04 23:36:10 +01:00
# Generic: WebAssembly
# ~*application/wasm 1y; # default
2022-12-04 23:36:10 +01:00
# Generic: Assets
# ~*application/javascript 1y; # default
# ~*application/x-javascript 1y; # default
# ~*text/javascript 1y; # default
# ~*text/css 1y; # default
2022-12-04 23:36:10 +01:00
# Generic: Medias
# ~*audio/ 1y; # default
# ~*image/ 1y; # default
# ~*video/ 1y; # default
# ~*font/ 1y; # default
}
expires $expires;