Created
May 26, 2018 05:08
-
-
Save danielpotthast/e66fa8e20fd2f0180a52ca0cdb2d0f7f to your computer and use it in GitHub Desktop.
NGINX – Snippet: Caching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fonts | |
if ( $uri ~* ^.+?\.(?:eot|svg|svgz|ttf|woff|woff2)$ ) { | |
expires 30d; | |
access_log off; | |
add_header Cache-Control "public"; | |
add_header Access-Control-Allow-Origin *; | |
} | |
# Feed | |
if ( $uri ~* ^.+?\.(?:rss|atom)$ ) { | |
expires 1h; | |
access_log off; | |
add_header Cache-Control "public"; | |
} | |
# Media: images, icons, video, audio | |
if ( $uri ~* ^.+?\.(?:jpg|jpeg|gif|png|ico|cur|gz|mp4|ogg|ogv|webm)$ ) { | |
expires 30d; | |
access_log off; | |
add_header Cache-Control "public"; | |
} | |
# CSS and Javascript | |
if ( $uri ~* ^.+?\.(?:css|js)$ ) { | |
expires 30d; | |
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