From 1478feb7aa4bb3a963dba7afd73af61d24fa4234 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Tue, 30 Apr 2019 22:10:11 -0600 Subject: [PATCH] doc: Explain the nginx ETag patch https://github.com/NixOS/nixpkgs/issues/25485 --- doc/package-notes.xml | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/doc/package-notes.xml b/doc/package-notes.xml index 12d81ae29bf..54f3079d554 100644 --- a/doc/package-notes.xml +++ b/doc/package-notes.xml @@ -918,4 +918,52 @@ citrix_receiver.override { +
+ Nginx + + + Nginx is a + reverse proxy and lightweight webserver. + + +
+ ETags on static files served from the Nix store + + + HTTP has a couple different mechanisms for caching to prevent + clients from having to download the same content repeatedly + if a resource has not changed since the last time it was requested. + When nginx is used as a server for static files, it implements + the caching mechanism based on the + Last-Modified + response header automatically; unfortunately, it works by using + filesystem timestamps to determine the value of the + Last-Modified header. This doesn't give the + desired behavior when the file is in the Nix store, because all + file timestamps are set to 0 (for reasons related to build + reproducibility). + + + + Fortunately, HTTP supports an alternative (and more effective) + caching mechanism: the + ETag + response header. The value of the ETag header + specifies some identifier for the particular content that the + server is sending (e.g. a hash). When a client makes a second + request for the same resource, it sends that value back in an + If-None-Match header. If the ETag value is + unchanged, then the server does not need to resend the content. + + + + As of NixOS 19.09, the nginx package in Nixpkgs is patched such + that when nginx serves a file out of /nix/store, + the hash in the store path is used as the ETag + header in the HTTP response, thus providing proper caching functionality. + This happens automatically; you do not need to do modify any + configuration to get this behavior. + +
+