This repository was archived by the owner on Aug 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx.conf
More file actions
78 lines (66 loc) · 2.02 KB
/
nginx.conf
File metadata and controls
78 lines (66 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
etag on;
gzip on;
gzip_comp_level 6;
gzip_min_length 1024;
gzip_vary on;
gzip_proxied any;
gzip_disable "msie6";
gzip_types
text/plain
text/css
text/javascript
application/javascript
application/json
application/xml
application/rss+xml
application/atom+xml
application/vnd.ms-fontobject
font/ttf
font/otf
image/svg+xml;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
# Never cache the HTML entrypoint
location = /index.html {
add_header Cache-Control "no-store, no-cache, must-revalidate" always;
add_header Pragma "no-cache" always;
add_header Expires "0" always;
}
# Never cache the service worker
location = /sw.js {
add_header Cache-Control "no-store, no-cache, must-revalidate" always;
add_header Pragma "no-cache" always;
add_header Expires "0" always;
}
# Long-cache only hashed JS/CSS (immutable)
location ~* "-[A-Za-z0-9]{8,}\.(?:js|css)(?:\.map)?$" {
add_header Cache-Control "public, max-age=31536000, immutable" always;
}
# Short TTL for non-hashed JS/CSS
location ~* "\.(?:js|css)$" {
add_header Cache-Control "public, max-age=600, must-revalidate" always;
}
# Short TTL for images and fonts
location ~* "\.(?:png|jpg|jpeg|gif|ico|svg|ttf|woff|woff2)$" {
add_header Cache-Control "public, max-age=600, must-revalidate" always;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}