1
mirror of https://github.com/jakejarvis/mastodon-utils.git synced 2025-04-26 02:15:22 -04:00

send fewer requests for static files to the backend

This commit is contained in:
Jake Jarvis 2022-12-16 17:37:37 -05:00
parent 30f958e1c5
commit 07f3d6fa8b
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39

View File

@ -63,11 +63,6 @@ server {
font/eot font/opentype font/otf font/truetype image/svg+xml image/vnd.microsoft.icon
image/x-icon image/x-win-bitmap text/css text/javascript text/plain text/xml;
# add shortcut to public Grafana dashboard
location ~ ^/dashboard/?$ {
return 302 https://grafana.pipe.fail/public-dashboards/b5ca7a7c8e844f90b0973d2ab02bad0a;
}
# sends most paths to the backend proxy and ignores the location blocks below, except if
# the file exists in /home/mastodon/live
location / {
@ -76,7 +71,7 @@ server {
}
# condensed version of original Mastodon nginx.conf
location ~ ^/(assets|avatars|emoji|headers|packs|shortcuts|sounds)/ {
location ~ ^/(?:assets|avatars|emoji|headers|packs|shortcuts|sounds)/ {
add_header Cache-Control "public, max-age=2419200, must-revalidate"; # 28 days
add_header Strict-Transport-Security "max-age=63072000" always;
try_files $uri =404;
@ -89,11 +84,11 @@ server {
try_files $uri =404;
}
# static files in root of /public (sw.js, favicon.ico, etc) that aren't covered above
location ~ ^/(.*\.(js|css|png|gif|jpg|txt|ico))$ {
# static files *only in the root* of /public (/favicon.ico, /sw.js, /robots.txt, etc.)
location ~ ^/[^/]+\.(?:js|css|png|gif|jpg|txt|ico)$ {
add_header Cache-Control "public, max-age=604800, must-revalidate"; # 7 days
add_header Strict-Transport-Security "max-age=63072000" always;
try_files $uri @proxy;
try_files $uri =404;
}
location ^~ /api/v1/streaming {