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

77 lines
2.5 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
# 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 {
2021-11-14 22:18:27 +01:00
default 1y;
# No content
"" off;
# CSS
~*text/css 1y;
# Data interchange
~*application/atom\+xml 1h;
~*application/rdf\+xml 1h;
~*application/rss\+xml 1h;
2022-10-28 10:44:28 +02:00
~*application/json epoch;
~*application/ld\+json epoch;
~*application/schema\+json epoch;
~*application/geo\+json epoch;
~*application/xml epoch;
~*text/calendar epoch;
~*text/xml epoch;
# Favicon (cannot be renamed!) and cursor images
~*image/vnd.microsoft.icon 1w;
~*image/x-icon 1w;
# HTML
2022-10-28 10:44:28 +02:00
~*text/html epoch;
# JavaScript
~*application/javascript 1y;
~*application/x-javascript 1y;
~*text/javascript 1y;
# Manifest files
~*application/manifest\+json 1w;
2022-10-28 10:44:28 +02:00
~*application/x-web-app-manifest\+json epoch;
~*text/cache-manifest epoch;
# Markdown
2022-10-28 10:44:28 +02:00
~*text/markdown epoch;
# Media files
~*audio/ 1y;
~*image/ 1y;
~*video/ 1y;
# WebAssembly
~*application/wasm 1y;
# Web fonts
~*font/ 1y;
~*application/vnd.ms-fontobject 1y;
~*application/x-font-ttf 1y;
~*application/x-font-woff 1y;
~*application/font-woff 1y;
~*application/font-woff2 1y;
# Other
~*text/x-cross-domain-policy 1w;
}
expires $expires;