From 06a5fb2adab413ff761a303d5de7914032b08ed2 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sun, 26 Aug 2018 21:43:34 +0200 Subject: [PATCH 1/2] nginx: use a compression level of 5 in recommended configuration While there is little gain of space to use a compression level of 9, the CPU usage is significant. Many experiments point to use something between 4 and 6. For example: - https://mjanja.ch/2015/03/finding-the-nginx-gzip_comp_level-sweet-spot/ - https://github.com/h5bp/server-configs-nginx/blob/3bda5b93edba147d51760e900c2079828a7dc274/nginx.conf#L93 --- nixos/modules/services/web-servers/nginx/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/web-servers/nginx/default.nix b/nixos/modules/services/web-servers/nginx/default.nix index 355976c4b7c..4359b3f8b6f 100644 --- a/nixos/modules/services/web-servers/nginx/default.nix +++ b/nixos/modules/services/web-servers/nginx/default.nix @@ -92,7 +92,7 @@ let gzip on; gzip_disable "msie6"; gzip_proxied any; - gzip_comp_level 9; + gzip_comp_level 5; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; gzip_vary on; ''} From bd075eb914ca16ce9f35211445733f72ddaf0127 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sun, 26 Aug 2018 21:48:55 +0200 Subject: [PATCH 2/2] nginx: add more gzipped MIME types The additions are: - image/svg+xml for SVG images - application/atom+xml for Atom feeds These types are also present in mime.types. For better readability, the list is sorted and formatted with one type per line. --- nixos/modules/services/web-servers/nginx/default.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/web-servers/nginx/default.nix b/nixos/modules/services/web-servers/nginx/default.nix index 4359b3f8b6f..17b169f7c69 100644 --- a/nixos/modules/services/web-servers/nginx/default.nix +++ b/nixos/modules/services/web-servers/nginx/default.nix @@ -93,7 +93,17 @@ let gzip_disable "msie6"; gzip_proxied any; gzip_comp_level 5; - gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + gzip_types + application/atom+xml + application/javascript + application/json + application/xml + application/xml+rss + image/svg+xml + text/css + text/javascript + text/plain + text/xml; gzip_vary on; ''}