move Cache-Control header to server block, making js location unnecessary

This commit is contained in:
El RIDO 2021-10-13 19:55:02 +02:00
parent f15474e7c8
commit 25abb55cd0
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92

View file

@ -5,6 +5,10 @@ server {
root /var/www;
index index.php index.html index.htm;
# no-transform tells Cloudflare and others to not change the content of
# the file and thus breaking SRI.
# https://developers.cloudflare.com/cache/about/cache-control#other
add_header Cache-Control "public, max-age=3600, must-revalidate, no-transform";
add_header Cross-Origin-Embedder-Policy require-corp;
add_header Cross-Origin-Resource-Policy same-origin;
add_header Cross-Origin-Opener-Policy same-origin;
@ -18,14 +22,6 @@ server {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.js$ {
# no-transform tells Cloudflare and others to not change the content of
# the file and thus breaking SRI.
# https://developers.cloudflare.com/cache/about/cache-control#other
add_header Cache-Control "public, max-age=3600, must-revalidate, no-transform";
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include /etc/nginx/location.d/*.conf;
fastcgi_pass unix:/run/php-fpm.sock;
@ -33,6 +29,7 @@ server {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_hide_header Cache-Control;
fastcgi_hide_header Cross-Origin-Embedder-Policy;
fastcgi_hide_header Cross-Origin-Resource-Policy;
fastcgi_hide_header Cross-Origin-Opener-Policy;