Skip to content

Instantly share code, notes, and snippets.

@dorfo-dev
Forked from lukecav/ngnix.config
Created July 15, 2022 16:02
Show Gist options
  • Save dorfo-dev/50e23f42b64ec6d531648bbe1ab97990 to your computer and use it in GitHub Desktop.
Save dorfo-dev/50e23f42b64ec6d531648bbe1ab97990 to your computer and use it in GitHub Desktop.
Browser caching rules for NGNIX and expire headers.
# Browser caching of static assets.
location ~* \.(jpg|jpeg|png|gif|ico|css|js|pdf)$ {
expires 7d;
add_header Cache-Control "public, no-transform";
}
# Media: images, icons, video, audio send expires headers
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
# Web fonts send expires headers
location ~* \.(?:eot|otf|ttf|woff|woff2)$ {
expires 3M;
access_log off;
add_header Cache-Control "public";
}
# CSS and Javascript send expires headers.
location ~* \.(?:css|js)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}
# HTML send expires headers.
location ~* \.(html)$ {
expires 7d;
access_log off;
add_header Cache-Control "public";
}
@dorfo-dev
Copy link
Author

config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment