Skip to content

Commit 7841e03

Browse files
authored
fix: make nginx respect expiration better
1 parent 879d59e commit 7841e03

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

nginx.conf

+17-16
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ http {
1818
if ($host ~ ^www\.(?<domain>.+)$) {
1919
return 301 $scheme://$domain$request_uri;
2020
}
21-
21+
server_tokens off;
2222
server_name _;
2323

2424
root /usr/share/nginx/html;
@@ -47,33 +47,22 @@ http {
4747
try_files $uri $uri.html $uri/index.html /$uri /$uri/index.html =404;
4848
}
4949

50-
# Media: images, icons, video, audio, HTC
51-
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|mp3|ogg|ogv|webp|webm|htc|woff2|woff)$ {
52-
expires 1y;
53-
access_log off;
54-
}
55-
56-
# CSS and Javascript
57-
location ~* \.(?:css|js)$ {
58-
expires 1y;
59-
access_log off;
60-
}
6150

6251
# Plausible script
63-
location /js/script.js {
52+
location = /js/script.js {
6453
# Change this if you use a different variant of the script
6554
proxy_pass https://plausible.io/js/script.js;
6655
proxy_set_header Host plausible.io;
6756

6857
# Tiny, negligible performance improvement. Very optional.
6958
proxy_buffering on;
7059

71-
# make cache WAY lighter
72-
expires 1d;
60+
# make cache WAY lighter
61+
expires 1d;
7362
}
7463

7564
# Plausible script
76-
location /api/event {
65+
location = /api/event {
7766
proxy_pass https://plausible.io/api/event;
7867
proxy_set_header Host plausible.io;
7968
proxy_buffering on;
@@ -83,5 +72,17 @@ http {
8372
proxy_set_header X-Forwarded-Proto $scheme;
8473
proxy_set_header X-Forwarded-Host $host;
8574
}
75+
76+
# Media: images, icons, video, audio, HTC
77+
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|mp3|ogg|ogv|webp|webm|htc|woff2|woff)$ {
78+
expires 1y;
79+
access_log off;
80+
}
81+
82+
# CSS and Javascript
83+
location ~* \.(?:css|js)$ {
84+
expires 1y;
85+
access_log off;
86+
}
8687
}
8788
}

0 commit comments

Comments
 (0)