NGINX – Snippet: Caching
# 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