avoid sending unnecessary push cookie

This commit is contained in:
Daniel Micay 2021-12-04 07:59:53 -05:00
parent 0a2a791a2c
commit fddfa68695
2 changed files with 12 additions and 3 deletions

View File

@ -72,11 +72,20 @@ http {
if_modified_since before;
map $http_cookie $preload_resources {
"~*__Host-preload=1" "<{{path|/main.css}}>; rel=preload; nopush; as=style; integrity={{integrity|/main.css}}, </fonts/roboto-v29-regular-latin.woff2>; rel=preload; nopush; as=font; crossorigin, </fonts/roboto-v29-bold-latin.woff2>; rel=preload; nopush; as=font; crossorigin, <{{path|/mask-icon.svg}}>; rel=preload; nopush; as=image";
map $http_cookie $nopush {
"~*__Host-preload=1" 1;
default 0;
}
map $nopush $preload_resources {
1 "<{{path|/main.css}}>; rel=preload; nopush; as=style; integrity={{integrity|/main.css}}, </fonts/roboto-v29-regular-latin.woff2>; rel=preload; nopush; as=font; crossorigin, </fonts/roboto-v29-bold-latin.woff2>; rel=preload; nopush; as=font; crossorigin, <{{path|/mask-icon.svg}}>; rel=preload; nopush; as=image";
default "<{{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, <{{path|/mask-icon.svg}}>; rel=preload; as=image";
}
map $nopush $push_cookie {
0 "__Host-preload=1; HttpOnly; Secure; SameSite=Lax; Path=/";
}
server {
listen 80 backlog=4096;
listen [::]:80 backlog=4096;

View File

@ -1,3 +1,3 @@
add_header Link $preload_resources always;
add_header Set-Cookie "__Host-preload=1; HttpOnly; Secure; SameSite=Lax; Path=/" always;
add_header Set-Cookie $push_cookie always;
http2_push_preload on;