Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php text/html files no longer br encoded ? #22

Closed
centminmod opened this issue Mar 29, 2016 · 11 comments
Closed

php text/html files no longer br encoded ? #22

centminmod opened this issue Mar 29, 2016 · 11 comments

Comments

@centminmod
Copy link

Previous ngx_brotli versions showed br encoding for php files with text/html mime types. But latest with Nginx 1.9.12-1.9.13 seem to do br encoding only for static files except php files ?

nginx -V
nginx version: nginx/1.9.13
built by gcc 4.9.1 20140922 (Red Hat 4.9.1-10) (GCC)
built with LibreSSL 2.3.3
TLS SNI support enabled
configure arguments: --with-ld-opt='-lrt -ljemalloc -Wl,-z,relro -Wl,-rpath,/usr/local/lib' --with-cc-opt='-m64 -mtune=native -mfpmath=sse -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2' --sbin-path=/usr/local/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --with-http_stub_status_module --with-http_secure_link_module --with-openssl-opt=enable-tlsext --add-module=../nginx-module-vts --with-libatomic --with-threads --with-stream=dynamic --with-stream_ssl_module --with-http_gzip_static_module --add-dynamic-module=../ngx_brotli --add-dynamic-module=../ngx_pagespeed-release-1.10.33.6-beta --with-http_sub_module --with-http_addition_module --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_realip_module --add-module=../ngx-fancyindex-0.3.6 --add-module=../ngx_cache_purge-2.3 --add-module=../ngx_devel_kit-0.3.0rc1 --add-module=../set-misc-nginx-module-0.30 --add-module=../echo-nginx-module-0.58 --add-module=../redis2-nginx-module-0.12 --add-module=../ngx_http_redis-0.3.7 --add-module=../nginx_upstream_check_module-0.3.0 --add-module=../openresty-memc-nginx-module-4f6f78f --add-module=../srcache-nginx-module-0.30 --add-module=../headers-more-nginx-module-0.29 --with-pcre=../pcre-8.38 --with-pcre-jit --with-http_ssl_module --with-http_v2_module --with-openssl=../libressl-2.3.3

i am currently using older ngx_brotli version and php files get working br encoding https://community.centminmod.com/

git log

git log -1
commit 86998c61fab726d4ee21fdf7e96f80e0cffbc71a
Author: Piotr Sikora <>
Date:   Tue Feb 9 19:34:36 2016 -0800

    Brotli: add support for dynamic modules.

    Fixes build with nginx-1.9.11+.

    Signed-off-by: Piotr Sikora <>
@PiotrSikora
Copy link
Contributor

Interesting... Works here... Just to make sure, you're using load_module to load both: ngx_http_brotli_filter_module.so and ngx_http_brotli_static_module.so, right?

Could you try without other modules and/or when compiling ngx_brotli as a builtin module?

@centminmod
Copy link
Author

yes i am - just noticed something interesting on recompiles old dynamic modules get tagged with .old at the end ?

/usr/local/nginx/modules
total 35M
drwxr-xr-x  2 root root 4.0K Mar 30 00:40 .
drwxr-xr-x 10 root root 4.0K Mar 25 08:24 ..
-rwxr-xr-x  1 root root 207K Mar 30 00:40 ngx_http_brotli_filter_module.so
-rwxr-xr-x  1 root root 106K Mar 30 00:40 ngx_http_brotli_static_module.so
-rwxr-xr-x  1 root root 123K Mar 30 00:40 ngx_http_geoip_module.so
-rwxr-xr-x  1 root root 123K Mar 30 00:21 ngx_http_geoip_module.so.old
-rwxr-xr-x  1 root root 134K Mar 30 00:40 ngx_http_image_filter_module.so
-rwxr-xr-x  1 root root 134K Mar 30 00:21 ngx_http_image_filter_module.so.old
-rwxr-xr-x  1 root root  17M Mar 30 00:40 ngx_pagespeed.so
-rwxr-xr-x  1 root root  17M Mar 30 00:21 ngx_pagespeed.so.old
-rwxr-xr-x  1 root root 546K Mar 30 00:40 ngx_stream_module.so
-rwxr-xr-x  1 root root 546K Mar 30 00:21 ngx_stream_module.so.old

tried ngx_brotli as non-dynamic module and same issue.

i'll try with other modules disabled and see

@centminmod
Copy link
Author

same issue with php files only with reduced nginx modules compiled

nginx -V
nginx version: nginx/1.9.13
built by clang 3.4.2 (tags/RELEASE_34/dot2-final)
built with LibreSSL 2.3.3
TLS SNI support enabled
configure arguments: --with-ld-opt='-lrt -ljemalloc -Wl,-z,relro -Wl,-rpath,/usr/local/lib' --with-cc-opt='-m64 -mtune=native -mfpmath=sse -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wno-sign-compare -Wno-string-plus-int -Wno-deprecated-declarations -Wno-unused-parameter -Wno-unused-const-variable -Wno-conditional-uninitialized -Wno-mismatched-tags -Wno-c++11-extensions -Wno-sometimes-uninitialized -Wno-parentheses-equality -Wno-tautological-compare -Wno-self-assign -Wno-deprecated-register -Wno-deprecated -Wno-invalid-source-encoding -Wno-pointer-sign -Wno-parentheses -Wno-enum-conversion -Wno-c++11-compat-deprecated-writable-strings -Wno-write-strings' --sbin-path=/usr/local/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --with-http_stub_status_module --with-openssl-opt=enable-tlsext --with-libatomic --with-threads --with-http_gzip_static_module --add-dynamic-module=../ngx_brotli --with-http_geoip_module=dynamic --with-http_realip_module --add-module=../ngx_cache_purge-2.3 --add-module=../ngx_http_redis-0.3.7 --add-module=../headers-more-nginx-module-0.29 --with-pcre=../pcre-8.38 --with-pcre-jit --with-http_ssl_module --with-http_v2_module --with-openssl=../libressl-2.3.3

and

load_module "modules/ngx_http_brotli_filter_module.so";
load_module "modules/ngx_http_brotli_static_module.so";
load_module "modules/ngx_http_geoip_module.so";

@PiotrSikora
Copy link
Contributor

How exactly are you testing? Browser? cURL?

@centminmod
Copy link
Author

via dev tool network tab in web browser firefox 44, firefox nightly and canary with brotli enabled

@PiotrSikora
Copy link
Contributor

Could you paste request & response headers?

Also, could you try with cURL and paste output (I'm assuming it's not public URL)?

curl -vso /dev/null -H"Accept-Encoding: gzip,br" localhost:8080/path/to/php/page.html

@centminmod
Copy link
Author

it's a local test wordpress site index page

chrome canary response header

content-encoding:gzip
content-type:text/html; charset=UTF-8
date:Wed, 30 Mar 2016 01:51:19 GMT
server:nginx centminmod
status:200
x-pingback:https://testdomain.com/xmlrpc.php
x-powered-by:centminmod

chrome canary request headers

:authority:testdomain.com
:method:GET
:path:/1/hello-world/
:scheme:https
accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
accept-encoding:gzip, deflate, sdch, br
accept-language:en-GB,en-US;q=0.8,en;q=0.6
cache-control:no-cache
dnt:1
pragma:no-cache
referer:https://testdomain.com/
upgrade-insecure-requests:1
user-agent:Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2693.2 Safari/537.36

css, js all report br encoding, just php index page reports gzip encoding

it's a localhost site with self-signed ssl certificate

curl -kI -H "Accept-Encoding: gzip,br" https://testdomain.com 
HTTP/1.1 200 OK
Date: Wed, 30 Mar 2016 02:12:49 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 3306
Last-Modified: Sat, 26 Mar 2016 17:42:11 GMT
Connection: keep-alive
Vary: Accept-Encoding
ETag: "56f6c9f3-cea"
Content-Encoding: gzip
Server: nginx centminmod
X-Powered-By: centminmod

css reports br encoding though

curl -kI -H "Accept-Encoding: gzip,br" https://testdomain.com/wp-content/themes/twentysixteen/style.css?ver=4.4.2
HTTP/1.1 200 OK
Date: Wed, 30 Mar 2016 02:13:36 GMT
Content-Type: text/css
Last-Modified: Sat, 26 Mar 2016 17:41:28 GMT
Connection: keep-alive
Vary: Accept-Encoding
ETag: W/"56f6c9c8-10b2a"
Server: nginx centminmod
X-Powered-By: centminmod
Expires: Fri, 29 Apr 2016 02:13:36 GMT
Cache-Control: max-age=2592000
Access-Control-Allow-Origin: *
Cache-Control: public, must-revalidate, proxy-revalidate
Content-Encoding: br

options used

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;

@PiotrSikora
Copy link
Contributor

Are you sure that your PHP backend isn't gzipping the HTML response?

Also, are you using exactly same nginx, nginx.conf and PHP backend when testing old (working) and new (not working) ngx_brotli?

@centminmod
Copy link
Author

yeah they're the same ..

ah ha, wordpress has keycdn cache enabler which like wp super cache has generated a static html gzipped cache of the page !!!!! so that is probably it :)

@PiotrSikora
Copy link
Contributor

So... was that it? Can we close this issue?

@centminmod
Copy link
Author

@PiotrSikora yup that was it, keycdn cache enable pre-compress static html cached pages in wordpress. When disabled pre-compress cached html pages it reports br encoding now

curl -kI -H "Accept-Encoding: gzip,br" https://testdomain.com 
HTTP/1.1 200 OK
Date: Wed, 30 Mar 2016 16:57:15 GMT
Content-Type: text/html; charset=utf-8
Last-Modified: Wed, 30 Mar 2016 16:56:18 GMT
Connection: keep-alive
Vary: Accept-Encoding
ETag: W/"56fc0532-26e6"
Server: nginx centminmod
X-Powered-By: centminmod
Content-Encoding: br

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants