Skip to content

Commit fc4a549

Browse files
committed
add preload/push for device monitoring web app JS
1 parent a7726fc commit fc4a549

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

nginx/nginx.conf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ http {
8686
server [::1]:8080 max_conns=1024 fail_timeout=1s;
8787
}
8888

89+
map $uri $preload_resources_uri {
90+
/index.html ", <{{path|/monitoring.js}}>; rel=modulepreload; integrity={{integrity|/monitoring.js}}";
91+
}
92+
8993
map $http_cookie $nopush {
9094
~__Host-preload=1 1;
9195
default 0;
@@ -107,6 +111,10 @@ http {
107111
0 /fonts/roboto-v29-bold-latin.woff2;
108112
}
109113

114+
map $nopush $push_monitoring {
115+
0 "{{path|/monitoring.js}}";
116+
}
117+
110118
server {
111119
listen 80 backlog=4096;
112120
listen [::]:80 backlog=4096;
@@ -152,6 +160,15 @@ http {
152160
return 301 $1/$2;
153161
}
154162

163+
location = / {
164+
include snippets/security-headers.conf;
165+
add_header Cross-Origin-Resource-Policy "same-origin" always;
166+
add_header Cache-Control "public, no-cache";
167+
include snippets/preload.conf;
168+
http2_push $push_monitoring;
169+
try_files /index.html =404;
170+
}
171+
155172
location = /security.txt {
156173
return 301 /.well-known/security.txt;
157174
}

nginx/snippets/preload.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
add_header Link "<{{path|/main.css}}>; rel=preload; as=style; integrity={{integrity|/main.css}}, </fonts/roboto-v29-regular-latin.woff2>; rel=preload; as=font; crossorigin, </fonts/roboto-v29-bold-latin.woff2>; rel=preload; as=font; crossorigin" always;
1+
add_header Link "<{{path|/main.css}}>; rel=preload; as=style; integrity={{integrity|/main.css}}, </fonts/roboto-v29-regular-latin.woff2>; rel=preload; as=font; crossorigin, </fonts/roboto-v29-bold-latin.woff2>; rel=preload; as=font; crossorigin$preload_resources_uri" always;
22
add_header Set-Cookie $push_cookie always;
33
http2_push $push_stylesheet;
44
http2_push $push_font_regular;

0 commit comments

Comments
 (0)