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