google / ngx_brotli

NGINX module for Brotli compression
BSD 2-Clause "Simplified" License
2.09k stars 215 forks source link

BR content-encoding only works with static files like .css .js #30

Closed draft1 closed 8 years ago

draft1 commented 8 years ago

But not working on full html pages.

My config:

brotli on; brotli_static on; brotli_min_length 1000; brotli_buffers 32 8k; brotli_comp_level 5; brotli_types text/plain text/css text/xml application/javascript application/x-javascript application/xml application/xml+rss application/ecmascript application/json image/svg+xml;

redburn commented 8 years ago

HTML pages are served with MIME type text/html, which is missing from brotli_types in your config.

draft1 commented 8 years ago

But it was stated on your docs that:

Responses with the text/html MIME type are always compressed.

redburn commented 8 years ago

Oh, my bad. Perhaps this issue https://github.com/google/ngx_brotli/issues/22 is relevant?

draft1 commented 8 years ago

Almost identical but I don't have full page caching enabled. Even for logged visitors still not showing br encoding for php/html pages.

PiotrSikora commented 8 years ago

Sorry, but you didn't provide any useful information.

Could you paste output of:

curl -vso /dev/null -H"Accept-Encoding: gzip, br" http://path/to/your.html

?

And, ideally, the same curl against your backend server (not NGINX)?

draft1 commented 8 years ago

From my desktop: `curl -vso /dev/null -H"Accept-Encoding: gzip, br" https://domain.com/

I'm not using any other backend server, just pure Nginx.

draft1 commented 8 years ago

From the server itself: `# curl -vso /dev/null -H"Accept-Encoding: gzip, br" https://domain.com/

PiotrSikora commented 8 years ago

I'm not using any other backend server, just pure Nginx.

Uhm, there is xf_session cookie in the response headers, so there is definitely something more than just NGINX...

Anyway, it looks that your backend compresses response with gzip (and NGINX doesn't recompress it with Brotli, by design).

Could you try adding:

proxy_set_header "Accept-Encoding" "";

to your proxy location, so that backend doesn't see Accept-Encoding header?

redburn commented 8 years ago

https://xenforo.com/help/config-php-options/

enableGzip is set to true by default. Change it to false to have nginx (instead of PHP) handle the compression of text/html responses.

draft1 commented 8 years ago

Thanks lot! Fixed now with this config for XenForo: $config['enableGzip'] = false;

centminmod commented 8 years ago

that's strange my xenforo works with brotli and i didn't need to disable xenforo gzip !

rugk commented 8 years ago

that's strange my xenforo works with brotli and i didn't need to disable xenforo gzip !

Have you tested whether XenForo actually uses gzip? Additionally I think you should disable GZIP there anyway when you compress the files with the webserver as the PHP implementation is quite certainly slower and useless when you use Brotli.