From 8db768bd61094ad814bb56b8a2a560ccc416aef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Colombaro?= Date: Thu, 16 May 2019 22:57:57 +0200 Subject: [PATCH] Pre-compressed content usage config files Closes #231 --- h5bp/web_performance/compression.conf | 6 ------ .../pre-compressed_content_brotli.conf | 17 +++++++++++++++++ .../pre-compressed_content_gzip.conf | 13 +++++++++++++ test/vhosts/server.localhost.conf | 2 +- 4 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 h5bp/web_performance/pre-compressed_content_brotli.conf create mode 100644 h5bp/web_performance/pre-compressed_content_gzip.conf diff --git a/h5bp/web_performance/compression.conf b/h5bp/web_performance/compression.conf index 7f4b733..8cc7d90 100644 --- a/h5bp/web_performance/compression.conf +++ b/h5bp/web_performance/compression.conf @@ -63,9 +63,3 @@ gzip_types text/vtt text/x-component text/x-cross-domain-policy; - -# This should be turned on if you are going to have pre-compressed copies (.gz) -# of static files available. If not it should be left off as it will cause extra -# I/O for the check. It is best if you enable this in a `location` block for a -# specific directory, or on an individual `server` level. -# gzip_static on; diff --git a/h5bp/web_performance/pre-compressed_content_brotli.conf b/h5bp/web_performance/pre-compressed_content_brotli.conf new file mode 100644 index 0000000..fda8806 --- /dev/null +++ b/h5bp/web_performance/pre-compressed_content_brotli.conf @@ -0,0 +1,17 @@ +# ---------------------------------------------------------------------- +# | Brotli pre-compressed content | +# ---------------------------------------------------------------------- + +# Serve brotli compressed files if they exist and if the client accepts brotli +# encoding. +# +# (!) To make this part relevant, you need to generate encoded files by your +# own. Enabling this part will not auto-generate brotlied files. +# +# Note that some clients (eg. browsers) require a secure connection to request +# brotli-compressed resources. +# https://www.chromestatus.com/feature/5420797577396224 +# +# https://github.com/eustas/ngx_brotli/#brotli_static + +brotli_static on; diff --git a/h5bp/web_performance/pre-compressed_content_gzip.conf b/h5bp/web_performance/pre-compressed_content_gzip.conf new file mode 100644 index 0000000..1809bfe --- /dev/null +++ b/h5bp/web_performance/pre-compressed_content_gzip.conf @@ -0,0 +1,13 @@ +# ---------------------------------------------------------------------- +# | GZip pre-compressed content | +# ---------------------------------------------------------------------- + +# Serve gzip compressed files if they exist and if the client accepts gzip +# encoding. +# +# (!) To make this part relevant, you need to generate encoded files by your +# own. Enabling this part will not auto-generate gziped files. +# +# https://nginx.org/en/docs/http/ngx_http_gzip_static_module.html + +gzip_static on; diff --git a/test/vhosts/server.localhost.conf b/test/vhosts/server.localhost.conf index b345333..c862061 100644 --- a/test/vhosts/server.localhost.conf +++ b/test/vhosts/server.localhost.conf @@ -25,6 +25,6 @@ server { include h5bp/errors/custom_errors.conf; location ~* /test-pre-gzip { - gzip_static on; + include h5bp/web_performance/pre-compressed_content_gzip.conf; } }