Add gzip support to the sample nginx configuration
authorMicah Elizabeth Scott <micah@misc.name>
Wed, 22 Aug 2018 21:34:41 +0000 (14:34 -0700)
committerChocobozzz <me@florianbigard.com>
Fri, 24 Aug 2018 07:08:33 +0000 (09:08 +0200)
Without gzip explicitly enabled, load times suffer from transferring
over a megabyte of plaintext javascript. With gzip enabled, the bundle
is down to about 300K, and loads much faster.

This change does not enable gzip on files that are already compressed,
so images, fonts, and videos will be sent without the CPU overhead.

support/nginx/peertube

index 01506c7aa54e5bbd79ada58cdc37100b9094201d..1b698576f34f2c5a6fe9143047f3fd14f40b3fa9 100644 (file)
@@ -37,6 +37,11 @@ server {
   # resolver $DNS-IP-1 $DNS-IP-2 valid=300s;
   # resolver_timeout 5s;
 
+  # Enable compression for JS/CSS/HTML and JSON, for improved client load times
+  gzip on;
+  gzip_types text/plain text/css text/html application/javascript application/json;
+  gzip_vary on;
+
   add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
 
   access_log /var/log/nginx/peertube.example.com.access.log;