diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2021-12-04 07:59:53 -0500 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2021-12-04 07:59:53 -0500 |
| commit | fddfa68695afadd0a65939214dd47035cbe1667e (patch) | |
| tree | 75b7bed90cb70294e9836fe20cd7e811af55d0a9 | |
| parent | 0a2a791a2c86758d1080bb1daaeed797731a342e (diff) | |
avoid sending unnecessary push cookie
| -rw-r--r-- | nginx/nginx.conf | 13 | ||||
| -rw-r--r-- | nginx/snippets/preload.conf | 2 |
2 files changed, 12 insertions, 3 deletions
diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 50bac151..f113b958 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -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; diff --git a/nginx/snippets/preload.conf b/nginx/snippets/preload.conf index c3f2d886..8b369f5a 100644 --- a/nginx/snippets/preload.conf +++ b/nginx/snippets/preload.conf @@ -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; |
