- Add this code to your website's NGINX configuration, in /var/www/yourwebsite/conf/nginx/
- "nginx -t" and "service nginx reload" to apply the modification.
Last active
July 29, 2020 20:44
-
-
Save solid-pixel/f10522157c5717d25fcd4530fb22d8e7 to your computer and use it in GitHub Desktop.
Leverage Browser Caching with NGINX
This file contains hidden or 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
location ~* \.(?:css|js|txt)$ { | |
expires 1y; | |
sendfile on; | |
tcp_nopush on; | |
tcp_nodelay off; | |
add_header Cache-Control "public"; | |
} | |
#Media: images, icons, video, audio, HTC | |
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { | |
expires 1M; | |
access_log off; | |
add_header Cache-Control "public"; | |
} | |
location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ { | |
expires 1M; | |
sendfile on; | |
tcp_nopush on; | |
tcp_nodelay off; | |
add_header Cache-Control "public"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment