Skip to content

Instantly share code, notes, and snippets.

@aprakasa
Created December 3, 2018 13:38
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aprakasa/4409b11128651214db40e0fdd619bb0d to your computer and use it in GitHub Desktop.
Save aprakasa/4409b11128651214db40e0fdd619bb0d to your computer and use it in GitHub Desktop.
Nginx expire headers
location ~* \.(?:css|js|txt)$ {
expires 1M;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
add_header Cache-Control "public";
}
location ~* \.(?:json|xml|rss|atom)$ {
expires 1h;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
add_header Cache-Control "public";
}
location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ {
expires 3M;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
add_header Cache-Control "public";
}
#Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|webp|gif|png|ico|cur|zip|tgz|gz|rar|bz2|tar|svg|svgz|mp4|ogg|ogv|webm|mid|midi|wav|bmp|rtf|htc)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment