Created
April 8, 2025 07:38
-
-
Save rogerthomas84/4197e619ac4aebffcd956b1799f8daa9 to your computer and use it in GitHub Desktop.
Favicons 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
# In the server tag: | |
include /etc/nginx/locations.conf.d/favicons.conf; |
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
# Favicons, cached for 30 days | |
location ~* ^/(android-|safari-|apple-|browserconfig|ms-icon|mstile|favico|manifest|site|web-)(.*)\.(png|svg|xml|ico|json|webmanifest)$ { | |
# Only allow GET and OPTIONS requests | |
if ($request_method !~ ^(GET|OPTIONS)$) { | |
return 405; | |
} | |
expires 30d; | |
add_header Vary Accept-Encoding; | |
access_log off; | |
root '/srv/public/assets/favicons'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment