mirror of
https://github.com/discourse/discourse.git
synced 2025-04-27 22:54:41 +08:00
PERF: Enable brotli in NGINX (#32333)
This enables on-the-fly brotli compression at level 4 for all responses which we currently gzip. This level should provide slightly improved file sizes when compared to gzip, as well as slightly faster processing times. This is the [level which Cloudflare use](https://blog.cloudflare.com/results-experimenting-brotli/) for dynamic responses. When compared to our existing gzip level-5 configuration, our own experiments confirm that it provides slightly faster compression, with slightly smaller file sizes. For static assets which are cached by CDNs/browsers, we use brotli level 6 for an even better compression ratio.
This commit is contained in:
parent
fe12500767
commit
c38b50994d
@ -54,6 +54,11 @@ server {
|
|||||||
gzip_types application/json text/css text/javascript application/x-javascript application/javascript image/svg+xml application/wasm font/ttf font/otf;
|
gzip_types application/json text/css text/javascript application/x-javascript application/javascript image/svg+xml application/wasm font/ttf font/otf;
|
||||||
gzip_proxied any;
|
gzip_proxied any;
|
||||||
|
|
||||||
|
brotli on;
|
||||||
|
brotli_min_length 1000;
|
||||||
|
brotli_comp_level 4;
|
||||||
|
brotli_types application/json text/css text/javascript application/x-javascript application/javascript image/svg+xml application/wasm font/ttf font/otf;
|
||||||
|
|
||||||
server_name _;
|
server_name _;
|
||||||
server_tokens off;
|
server_tokens off;
|
||||||
|
|
||||||
@ -225,6 +230,8 @@ server {
|
|||||||
# acceleration for backups, avatars, sprites and so on.
|
# acceleration for backups, avatars, sprites and so on.
|
||||||
# see note about repetition above
|
# see note about repetition above
|
||||||
location ~ ^/(svg-sprite/|letter_avatar/|letter_avatar_proxy/|user_avatar|highlight-js|stylesheets|theme-javascripts|favicon/proxied|service-worker|extra-locales/) {
|
location ~ ^/(svg-sprite/|letter_avatar/|letter_avatar_proxy/|user_avatar|highlight-js|stylesheets|theme-javascripts|favicon/proxied|service-worker|extra-locales/) {
|
||||||
|
brotli_comp_level 6;
|
||||||
|
|
||||||
# if Set-Cookie is in the response nothing gets cached
|
# if Set-Cookie is in the response nothing gets cached
|
||||||
# this is double bad cause we are not passing last modified in
|
# this is double bad cause we are not passing last modified in
|
||||||
proxy_ignore_headers "Set-Cookie";
|
proxy_ignore_headers "Set-Cookie";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user