centminmod / autoptimize-gzip

Autoptimize Gzip Wordpress Plugin hooks into Autoptimize API to enable pre-gzip compression of Autoptimize'd CSS & JS files
GNU General Public License v2.0
21 stars 2 forks source link

Add brotli static #2

Closed re-thc closed 5 years ago

re-thc commented 5 years ago

Similar to gzip_static except for brotli? It'd be nice to have since Brotli performs even better. Thanks.

centminmod commented 5 years ago

I only enable what autoptimize can provide in their code. So brotli compression request would need to be asked at https://github.com/futtta/autoptimize/ :)

futtta commented 5 years ago

And AO depends on availability of brotli in PHP core, which does not exist (yet)?

On Tue, Oct 16, 2018 at 7:45 AM George Liu (eva2000) < notifications@github.com> wrote:

I only enable what autoptimize can provide in their code. So brotli compression request would need to be asked at https://github.com/futtta/autoptimize/ :)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/centminmod/autoptimize-gzip/issues/2#issuecomment-430108511, or mute the thread https://github.com/notifications/unsubscribe-auth/AALEMZ8TNblKHoAG2_B7tMWy5wNP0Vbqks5ulXJlgaJpZM4Xdnnv .

centminmod commented 5 years ago

hey @futtta - there is a broti php extension at https://github.com/kjdev/php-ext-brotli. I will probably be adding to my Centmin Mod LEMP stacks PHP-FPM seeing as I already do it at Nginx level for brotli https://community.centminmod.com/threads/how-to-use-brotli-compression-for-centmin-mod-nginx-web-servers.10688/ :)

futtta commented 5 years ago

I've seen that, but (in AO's context) it's pretty useless to add something that is not available to 99,9% of users (as not in PHP core) :-)

On Tue, Oct 16, 2018 at 8:03 AM George Liu (eva2000) < notifications@github.com> wrote:

hey @futtta https://github.com/futtta - there is a broti php extension at https://github.com/kjdev/php-ext-brotli. I will probably be adding to my Centmin Mod LEMP stacks PHP-FPM seeing as I already do it at Nginx level for brotli https://community.centminmod.com/threads/how-to-use-brotli-compression-for-centmin-mod-nginx-web-servers.10688/ :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/centminmod/autoptimize-gzip/issues/2#issuecomment-430111754, or mute the thread https://github.com/notifications/unsubscribe-auth/AALEMXRKxpPQ1uYoM1N13HSKT3ks7bPFks5ulXaZgaJpZM4Xdnnv .

centminmod commented 5 years ago

Yeah true. Just did test install on my Centmin Mod LEMP stack ~ 2000-3000 new installs per month :) So if you do add brotli support to autoptimize, you know you'd have some folks willing to test it out ;)

php --ri brotli

brotli

Brotli support => enabled
Extension Version => 0.5.2
Library Version => 1.0.4
php -m
[PHP Modules]
bcmath
brotli
bz2
calendar
Core
ctype
curl
date
dom
enchant
exif
fileinfo
filter
ftp
gd
geoip
gettext
gmp
hash
iconv
igbinary
imagick
imap
intl
json
ldap
libxml
mailparse
mbstring
mcrypt
memcache
memcached
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
pspell
pthreads
readline
redis
Reflection
session
shmop
SimpleXML
snmp
soap
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache
futtta commented 5 years ago

well, add it in autoptimizeCache.php in the same function that does the static compression in a function_exists conditional, test it with and without brotli and if everything works fine do a PR and I'll happily accept :-)

On Tue, Oct 16, 2018 at 8:11 AM George Liu (eva2000) < notifications@github.com> wrote:

Yeah true. Just did test install on my Centmin Mod LEMP stack ~ 2000-3000 new installs per month :) So if you do add brotli support to autoptimize, you know you'd have some folks willing to test it out ;)

php --ri brotli

brotli

Brotli support => enabled Extension Version => 0.5.2 Library Version => 1.0.4

php -m [PHP Modules] bcmath brotli bz2 calendar Core ctype curl date dom enchant exif fileinfo filter ftp gd geoip gettext gmp hash iconv igbinary imagick imap intl json ldap libxml mailparse mbstring mcrypt memcache memcached mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql pdo_sqlite Phar posix pspell pthreads readline redis Reflection session shmop SimpleXML snmp soap sockets SPL sqlite3 standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl Zend OPcache zip zlib

[Zend Modules] Zend OPcache

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/centminmod/autoptimize-gzip/issues/2#issuecomment-430113276, or mute the thread https://github.com/notifications/unsubscribe-auth/AALEMctkC0sGqecUEKtW3VDBwibmAlzuks5ulXiWgaJpZM4Xdnnv .

centminmod commented 5 years ago

one problem - i'm not a php coder - just php consumer :)

futtta commented 5 years ago

OK, here's some completely untested code for you to play with then;

if ( apply_filters( 'autoptimize_filter_cache_create_static_gzip', false ) ) {
    // Create an additional cached gzip file.
    file_put_contents( $this->cachedir . $this->filename . '.gz', gzencode( $data, 9, FORCE_GZIP ) );
    // Create an additional cached brotli file if brotli_compress exists
    if ( function_exists( 'brotli_compress' ) ) {
       file_put_contents( $this->cachedir . $this->filename . '.br', brotli_compress( $data ) );
    }
}

(assumption; you want both the .gz and .br file to be there to allow you webserver to serve .gzip if the browser does not indicate br-support).

centminmod commented 5 years ago

Awesome. Made the alteration with the updated code in autoptimizeCache.php and installed autoptimize-gzip and looks to be working well with PHP 7.2.11 (php-fpm) on Centmin Mod 123.09beta01 LEMP stack based server for the pre-gzip/brotli compression at least

php -v
PHP 7.2.11 (cli) (built: Oct 16 2018 14:49:38) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.11, Copyright (c) 1999-2018, by Zend Technologies

install brotli PHP extension

cd /svr-setup
git clone --recursive --depth=1 https://github.com/kjdev/php-ext-brotli.git
cd php-ext-brotli
phpize
./configure
make -j$(nproc)
make install
echo "extension=brotli.so" > /etc/centminmod/php.d/brotli.ini
fpmrestart
php --ri brotli

brotli

Brotli support => enabled
Extension Version => 0.5.2
Library Version => 1.0.4

both pre-gzip and pre-brotli compressed assets shown ^_^

ls -lah wp-content/cache/autoptimize/{css,js}
wp-content/cache/autoptimize/css:
total 372K
drwxr-sr-x 2 nginx nginx 4.0K Oct 16 14:55 .
drwxr-sr-x 4 nginx nginx 4.0K Oct 16 14:55 ..
-rw-r--r-- 1 nginx nginx  48K Oct 16 14:55 autoptimize_f735042a33273526fb043c5a87f019d8.css
-rw-r--r-- 1 nginx nginx 6.6K Oct 16 14:55 autoptimize_f735042a33273526fb043c5a87f019d8.css.br
-rw-r--r-- 1 nginx nginx 7.6K Oct 16 14:55 autoptimize_f735042a33273526fb043c5a87f019d8.css.gz
-rw-r--r-- 1 nginx nginx 151K Oct 16 14:55 autoptimize_single_ced9eb36ba33532225a6f6a5b9c30ac8.css
-rw-r--r-- 1 nginx nginx  19K Oct 16 14:55 autoptimize_single_ced9eb36ba33532225a6f6a5b9c30ac8.css.br
-rw-r--r-- 1 nginx nginx  22K Oct 16 14:55 autoptimize_single_ced9eb36ba33532225a6f6a5b9c30ac8.css.gz
-rw-r--r-- 1 nginx nginx 6.2K Oct 16 14:55 autoptimize_snippet_02186534fc2cb75d30ffeb4e4060f935.css
-rw-r--r-- 1 nginx nginx 1.1K Oct 16 14:55 autoptimize_snippet_02186534fc2cb75d30ffeb4e4060f935.css.br
-rw-r--r-- 1 nginx nginx 1.3K Oct 16 14:55 autoptimize_snippet_02186534fc2cb75d30ffeb4e4060f935.css.gz
-rw-r--r-- 1 nginx nginx  37K Oct 16 14:55 autoptimize_snippet_11ba90148181e3f70031a87c63769326.css
-rw-r--r-- 1 nginx nginx 4.8K Oct 16 14:55 autoptimize_snippet_11ba90148181e3f70031a87c63769326.css.br
-rw-r--r-- 1 nginx nginx 5.5K Oct 16 14:55 autoptimize_snippet_11ba90148181e3f70031a87c63769326.css.gz
-rw-r--r-- 1 nginx nginx  277 Oct 16 14:55 autoptimize_snippet_c623142bb5ed0b70cb3fd1fc009ac97c.css
-rw-r--r-- 1 nginx nginx  139 Oct 16 14:55 autoptimize_snippet_c623142bb5ed0b70cb3fd1fc009ac97c.css.br
-rw-r--r-- 1 nginx nginx  203 Oct 16 14:55 autoptimize_snippet_c623142bb5ed0b70cb3fd1fc009ac97c.css.gz
-rw-r--r-- 1 nginx nginx 5.1K Oct 16 14:55 autoptimize_snippet_c94c9f38516a99b1f2ab4bfb5da9840d.css
-rw-r--r-- 1 nginx nginx 1.3K Oct 16 14:55 autoptimize_snippet_c94c9f38516a99b1f2ab4bfb5da9840d.css.br
-rw-r--r-- 1 nginx nginx 1.6K Oct 16 14:55 autoptimize_snippet_c94c9f38516a99b1f2ab4bfb5da9840d.css.gz
-rw-r--r-- 1 nginx nginx  189 Jun 26 22:11 index.html

wp-content/cache/autoptimize/js:
total 588K
drwxr-sr-x 2 nginx nginx 4.0K Oct 16 14:55 .
drwxr-sr-x 4 nginx nginx 4.0K Oct 16 14:55 ..
-rw-r--r-- 1 nginx nginx 162K Oct 16 14:55 autoptimize_cffafa51021979d9075b05e79de8dde5.js
-rw-r--r-- 1 nginx nginx  41K Oct 16 14:55 autoptimize_cffafa51021979d9075b05e79de8dde5.js.br
-rw-r--r-- 1 nginx nginx  46K Oct 16 14:55 autoptimize_cffafa51021979d9075b05e79de8dde5.js.gz
-rw-r--r-- 1 nginx nginx  20K Oct 16 14:55 autoptimize_snippet_14b16c0a613dccf79fea485ec09717a1.js
-rw-r--r-- 1 nginx nginx 6.3K Oct 16 14:55 autoptimize_snippet_14b16c0a613dccf79fea485ec09717a1.js.br
-rw-r--r-- 1 nginx nginx 7.0K Oct 16 14:55 autoptimize_snippet_14b16c0a613dccf79fea485ec09717a1.js.gz
-rw-r--r-- 1 nginx nginx  193 Oct 16 14:55 autoptimize_snippet_4ec3b19ffe467100c29c66bcc97ebc42.js
-rw-r--r-- 1 nginx nginx  136 Oct 16 14:55 autoptimize_snippet_4ec3b19ffe467100c29c66bcc97ebc42.js.br
-rw-r--r-- 1 nginx nginx  173 Oct 16 14:55 autoptimize_snippet_4ec3b19ffe467100c29c66bcc97ebc42.js.gz
-rw-r--r-- 1 nginx nginx 1.2K Oct 16 14:55 autoptimize_snippet_4fb38de1728cf7f23aa8b49d85bddde5.js
-rw-r--r-- 1 nginx nginx  496 Oct 16 14:55 autoptimize_snippet_4fb38de1728cf7f23aa8b49d85bddde5.js.br
-rw-r--r-- 1 nginx nginx  606 Oct 16 14:55 autoptimize_snippet_4fb38de1728cf7f23aa8b49d85bddde5.js.gz
-rw-r--r-- 1 nginx nginx 9.9K Oct 16 14:55 autoptimize_snippet_7121994eec5320fbe6586463bf9651c2.js
-rw-r--r-- 1 nginx nginx 3.5K Oct 16 14:55 autoptimize_snippet_7121994eec5320fbe6586463bf9651c2.js.br
-rw-r--r-- 1 nginx nginx 4.0K Oct 16 14:55 autoptimize_snippet_7121994eec5320fbe6586463bf9651c2.js.gz
-rw-r--r-- 1 nginx nginx 1014 Oct 16 14:55 autoptimize_snippet_7567776c328ea6a29916d6cbb521bed6.js
-rw-r--r-- 1 nginx nginx  398 Oct 16 14:55 autoptimize_snippet_7567776c328ea6a29916d6cbb521bed6.js.br
-rw-r--r-- 1 nginx nginx  518 Oct 16 14:55 autoptimize_snippet_7567776c328ea6a29916d6cbb521bed6.js.gz
-rw-r--r-- 1 nginx nginx 121K Oct 16 14:55 autoptimize_snippet_b2d9157ba53608c1226db7a16568b0e8.js
-rw-r--r-- 1 nginx nginx  29K Oct 16 14:55 autoptimize_snippet_b2d9157ba53608c1226db7a16568b0e8.js.br
-rw-r--r-- 1 nginx nginx  32K Oct 16 14:55 autoptimize_snippet_b2d9157ba53608c1226db7a16568b0e8.js.gz
-rw-r--r-- 1 nginx nginx 1.3K Oct 16 14:55 autoptimize_snippet_c2940304f2c898ad4391a9ea96e37e64.js
-rw-r--r-- 1 nginx nginx  471 Oct 16 14:55 autoptimize_snippet_c2940304f2c898ad4391a9ea96e37e64.js.br
-rw-r--r-- 1 nginx nginx  561 Oct 16 14:55 autoptimize_snippet_c2940304f2c898ad4391a9ea96e37e64.js.gz
-rw-r--r-- 1 nginx nginx  197 Oct 16 14:55 autoptimize_snippet_c5935bade23936a28a1b0f0eacd59912.js
-rw-r--r-- 1 nginx nginx  145 Oct 16 14:55 autoptimize_snippet_c5935bade23936a28a1b0f0eacd59912.js.br
-rw-r--r-- 1 nginx nginx  176 Oct 16 14:55 autoptimize_snippet_c5935bade23936a28a1b0f0eacd59912.js.gz
-rw-r--r-- 1 nginx nginx 7.9K Oct 16 14:55 autoptimize_snippet_d0c2c0d7e37652e66657c8c8d6376442.js
-rw-r--r-- 1 nginx nginx 2.2K Oct 16 14:55 autoptimize_snippet_d0c2c0d7e37652e66657c8c8d6376442.js.br
-rw-r--r-- 1 nginx nginx 2.5K Oct 16 14:55 autoptimize_snippet_d0c2c0d7e37652e66657c8c8d6376442.js.gz
-rw-r--r-- 1 nginx nginx  189 Jun 26 22:11 index.html

testing with Centmin Mod Nginx with ngx_brotli nginx module enabled

nginx -V     
nginx version: nginx/1.15.5 (161018-150231)
built by gcc 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC) 
built with OpenSSL 1.1.1  11 Sep 2018
TLS SNI support enabled

onfigure arguments: --with-ld-opt='-Wl,-E -L/usr/local/zlib-cf/lib -L/usr/local/lib -ljemalloc -Wl,-z,relro -Wl,-rpath,/usr/local/zlib-cf/lib:/usr/local/lib' --with-cc-opt='-I/usr/local/zlib-cf/include -I/usr/local/include -m64 -march=native -g -O3 -fstack-protector-strong -flto -fuse-ld=gold --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wimplicit-fallthrough=0 -fcode-hoisting -Wp,-D_FORTIFY_SOURCE=2 -Wno-deprecated-declarations -gsplit-dwarf' --sbin-path=/usr/local/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --build=161018-150231 --with-compat --with-http_stub_status_module --with-http_secure_link_module --with-libatomic --with-http_gzip_static_module --add-dynamic-module=../ngx_brotli --with-http_sub_module --with-http_addition_module --with-http_image_filter_module=dynamic --with-http_geoip_module --with-stream_geoip_module --with-stream_realip_module --with-stream_ssl_preread_module --with-threads --with-stream=dynamic --with-stream_ssl_module --with-http_realip_module --add-dynamic-module=../ngx-fancyindex-0.4.2 --add-module=../ngx_cache_purge-2.5 --add-dynamic-module=../ngx_devel_kit-0.3.0 --add-dynamic-module=../set-misc-nginx-module-0.32 --add-dynamic-module=../echo-nginx-module-0.61 --add-module=../redis2-nginx-module-0.15 --add-module=../ngx_http_redis-0.3.7 --add-module=../memc-nginx-module-0.18 --add-module=../srcache-nginx-module-0.31 --add-dynamic-module=../headers-more-nginx-module-0.33 --with-pcre-jit --with-http_ssl_module --with-http_v2_module --with-openssl=../openssl-1.1.1 --with-openssl-opt='enable-ec_nistp_64_gcc_128 enable-tls1_3'

matching up file sizes on disk for .br or .gz version for wp-content/cache/autoptimize/css/autoptimize_f735042a33273526fb043c5a87f019d8.css

ls -lah wp-content/cache/autoptimize/css/autoptimize_f735042a33273526fb043c5a87f019d8.css*
-rw-r--r-- 1 nginx nginx  48K Oct 16 14:55 wp-content/cache/autoptimize/css/autoptimize_f735042a33273526fb043c5a87f019d8.css
-rw-r--r-- 1 nginx nginx 6.6K Oct 16 14:55 wp-content/cache/autoptimize/css/autoptimize_f735042a33273526fb043c5a87f019d8.css.br
-rw-r--r-- 1 nginx nginx 7.6K Oct 16 14:55 wp-content/cache/autoptimize/css/autoptimize_f735042a33273526fb043c5a87f019d8.css.gz

via curl header checks

uncompressed

curl -I https://$domain/wp-content/cache/autoptimize/css/autoptimize_f735042a33273526fb043c5a87f019d8.css 
HTTP/1.1 200 OK
Date: Tue, 16 Oct 2018 15:13:08 GMT
Content-Type: text/css
Content-Length: 48767
Last-Modified: Tue, 16 Oct 2018 14:55:58 GMT
Connection: keep-alive
Vary: Accept-Encoding
ETag: "5bc5fbfe-be7f"
Server: nginx centminmod
X-Powered-By: centminmod
Expires: Thu, 15 Nov 2018 15:13:08 GMT
Cache-Control: max-age=2592000
Access-Control-Allow-Origin: *
Cache-Control: public, must-revalidate, proxy-revalidate, immutable, stale-while-revalidate=86400, stale-if-error=604800
Accept-Ranges: bytes

gzip

curl -I -H "Accept-Encoding: gzip" https://$domain/wp-content/cache/autoptimize/css/autoptimize_f735042a33273526fb043c5a87f019d8.css
HTTP/1.1 200 OK
Date: Tue, 16 Oct 2018 15:13:55 GMT
Content-Type: text/css
Content-Length: 7741
Last-Modified: Tue, 16 Oct 2018 14:55:58 GMT
Connection: keep-alive
Vary: Accept-Encoding
ETag: "5bc5fbfe-1e3d"
Content-Encoding: gzip
Server: nginx centminmod
X-Powered-By: centminmod
Expires: Thu, 15 Nov 2018 15:13:55 GMT
Cache-Control: max-age=2592000
Access-Control-Allow-Origin: *
Cache-Control: public, must-revalidate, proxy-revalidate, immutable, stale-while-revalidate=86400, stale-if-error=604800

brotli

curl -I -H "Accept-Encoding: br" https://$domain/wp-content/cache/autoptimize/css/autoptimize_f735042a33273526fb043c5a87f019d8.css    
HTTP/1.1 200 OK
Date: Tue, 16 Oct 2018 15:15:32 GMT
Content-Type: text/css
Content-Length: 6733
Last-Modified: Tue, 16 Oct 2018 14:55:58 GMT
Connection: keep-alive
Vary: Accept-Encoding
ETag: "5bc5fbfe-1a4d"
Content-Encoding: br
Server: nginx centminmod
X-Powered-By: centminmod
Expires: Thu, 15 Nov 2018 15:15:32 GMT
Cache-Control: max-age=2592000
Access-Control-Allow-Origin: *
Cache-Control: public, must-revalidate, proxy-revalidate, immutable, stale-while-revalidate=86400, stale-if-error=604800

Looks good so far @futtta 👍

futtta commented 5 years ago

OK, once you're sure this is OK ping me and I'll add to AO proper :)

On Tue, Oct 16, 2018 at 5:20 PM George Liu (eva2000) < notifications@github.com> wrote:

Awesome. Made the alteration with the updated code in autoptimizeCache.php and installed autoptimize-gzip https://github.com/centminmod/autoptimize-gzip and looks to be working well with PHP 7.2.11 (php-fpm) on Centmin Mod 123.09beta01 LEMP stack based server for the pre-gzip/brotli compression at least

php -v PHP 7.2.11 (cli) (built: Oct 16 2018 14:49:38) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.11, Copyright (c) 1999-2018, by Zend Technologies

cd /svr-setup git clone --recursive --depth=1 https://github.com/kjdev/php-ext-brotli.git cd php-ext-brotli phpize ./configure make -j$(nproc) make install echo "extension=brotli.so" > /etc/centminmod/php.d/brotli.ini fpmrestart

php --ri brotli

brotli

Brotli support => enabled Extension Version => 0.5.2 Library Version => 1.0.4

both pre-gzip and pre-brotli compressed assets shown ^_^

ls -lah wp-content/cache/autoptimize/{css,js} wp-content/cache/autoptimize/css: total 372K drwxr-sr-x 2 nginx nginx 4.0K Oct 16 14:55 . drwxr-sr-x 4 nginx nginx 4.0K Oct 16 14:55 .. -rw-r--r-- 1 nginx nginx 48K Oct 16 14:55 autoptimize_f735042a33273526fb043c5a87f019d8.css -rw-r--r-- 1 nginx nginx 6.6K Oct 16 14:55 autoptimize_f735042a33273526fb043c5a87f019d8.css.br -rw-r--r-- 1 nginx nginx 7.6K Oct 16 14:55 autoptimize_f735042a33273526fb043c5a87f019d8.css.gz -rw-r--r-- 1 nginx nginx 151K Oct 16 14:55 autoptimize_single_ced9eb36ba33532225a6f6a5b9c30ac8.css -rw-r--r-- 1 nginx nginx 19K Oct 16 14:55 autoptimize_single_ced9eb36ba33532225a6f6a5b9c30ac8.css.br -rw-r--r-- 1 nginx nginx 22K Oct 16 14:55 autoptimize_single_ced9eb36ba33532225a6f6a5b9c30ac8.css.gz -rw-r--r-- 1 nginx nginx 6.2K Oct 16 14:55 autoptimize_snippet_02186534fc2cb75d30ffeb4e4060f935.css -rw-r--r-- 1 nginx nginx 1.1K Oct 16 14:55 autoptimize_snippet_02186534fc2cb75d30ffeb4e4060f935.css.br -rw-r--r-- 1 nginx nginx 1.3K Oct 16 14:55 autoptimize_snippet_02186534fc2cb75d30ffeb4e4060f935.css.gz -rw-r--r-- 1 nginx nginx 37K Oct 16 14:55 autoptimize_snippet_11ba90148181e3f70031a87c63769326.css -rw-r--r-- 1 nginx nginx 4.8K Oct 16 14:55 autoptimize_snippet_11ba90148181e3f70031a87c63769326.css.br -rw-r--r-- 1 nginx nginx 5.5K Oct 16 14:55 autoptimize_snippet_11ba90148181e3f70031a87c63769326.css.gz -rw-r--r-- 1 nginx nginx 277 Oct 16 14:55 autoptimize_snippet_c623142bb5ed0b70cb3fd1fc009ac97c.css -rw-r--r-- 1 nginx nginx 139 Oct 16 14:55 autoptimize_snippet_c623142bb5ed0b70cb3fd1fc009ac97c.css.br -rw-r--r-- 1 nginx nginx 203 Oct 16 14:55 autoptimize_snippet_c623142bb5ed0b70cb3fd1fc009ac97c.css.gz -rw-r--r-- 1 nginx nginx 5.1K Oct 16 14:55 autoptimize_snippet_c94c9f38516a99b1f2ab4bfb5da9840d.css -rw-r--r-- 1 nginx nginx 1.3K Oct 16 14:55 autoptimize_snippet_c94c9f38516a99b1f2ab4bfb5da9840d.css.br -rw-r--r-- 1 nginx nginx 1.6K Oct 16 14:55 autoptimize_snippet_c94c9f38516a99b1f2ab4bfb5da9840d.css.gz -rw-r--r-- 1 nginx nginx 189 Jun 26 22:11 index.html

wp-content/cache/autoptimize/js: total 588K drwxr-sr-x 2 nginx nginx 4.0K Oct 16 14:55 . drwxr-sr-x 4 nginx nginx 4.0K Oct 16 14:55 .. -rw-r--r-- 1 nginx nginx 162K Oct 16 14:55 autoptimize_cffafa51021979d9075b05e79de8dde5.js -rw-r--r-- 1 nginx nginx 41K Oct 16 14:55 autoptimize_cffafa51021979d9075b05e79de8dde5.js.br -rw-r--r-- 1 nginx nginx 46K Oct 16 14:55 autoptimize_cffafa51021979d9075b05e79de8dde5.js.gz -rw-r--r-- 1 nginx nginx 20K Oct 16 14:55 autoptimize_snippet_14b16c0a613dccf79fea485ec09717a1.js -rw-r--r-- 1 nginx nginx 6.3K Oct 16 14:55 autoptimize_snippet_14b16c0a613dccf79fea485ec09717a1.js.br -rw-r--r-- 1 nginx nginx 7.0K Oct 16 14:55 autoptimize_snippet_14b16c0a613dccf79fea485ec09717a1.js.gz -rw-r--r-- 1 nginx nginx 193 Oct 16 14:55 autoptimize_snippet_4ec3b19ffe467100c29c66bcc97ebc42.js -rw-r--r-- 1 nginx nginx 136 Oct 16 14:55 autoptimize_snippet_4ec3b19ffe467100c29c66bcc97ebc42.js.br -rw-r--r-- 1 nginx nginx 173 Oct 16 14:55 autoptimize_snippet_4ec3b19ffe467100c29c66bcc97ebc42.js.gz -rw-r--r-- 1 nginx nginx 1.2K Oct 16 14:55 autoptimize_snippet_4fb38de1728cf7f23aa8b49d85bddde5.js -rw-r--r-- 1 nginx nginx 496 Oct 16 14:55 autoptimize_snippet_4fb38de1728cf7f23aa8b49d85bddde5.js.br -rw-r--r-- 1 nginx nginx 606 Oct 16 14:55 autoptimize_snippet_4fb38de1728cf7f23aa8b49d85bddde5.js.gz -rw-r--r-- 1 nginx nginx 9.9K Oct 16 14:55 autoptimize_snippet_7121994eec5320fbe6586463bf9651c2.js -rw-r--r-- 1 nginx nginx 3.5K Oct 16 14:55 autoptimize_snippet_7121994eec5320fbe6586463bf9651c2.js.br -rw-r--r-- 1 nginx nginx 4.0K Oct 16 14:55 autoptimize_snippet_7121994eec5320fbe6586463bf9651c2.js.gz -rw-r--r-- 1 nginx nginx 1014 Oct 16 14:55 autoptimize_snippet_7567776c328ea6a29916d6cbb521bed6.js -rw-r--r-- 1 nginx nginx 398 Oct 16 14:55 autoptimize_snippet_7567776c328ea6a29916d6cbb521bed6.js.br -rw-r--r-- 1 nginx nginx 518 Oct 16 14:55 autoptimize_snippet_7567776c328ea6a29916d6cbb521bed6.js.gz -rw-r--r-- 1 nginx nginx 121K Oct 16 14:55 autoptimize_snippet_b2d9157ba53608c1226db7a16568b0e8.js -rw-r--r-- 1 nginx nginx 29K Oct 16 14:55 autoptimize_snippet_b2d9157ba53608c1226db7a16568b0e8.js.br -rw-r--r-- 1 nginx nginx 32K Oct 16 14:55 autoptimize_snippet_b2d9157ba53608c1226db7a16568b0e8.js.gz -rw-r--r-- 1 nginx nginx 1.3K Oct 16 14:55 autoptimize_snippet_c2940304f2c898ad4391a9ea96e37e64.js -rw-r--r-- 1 nginx nginx 471 Oct 16 14:55 autoptimize_snippet_c2940304f2c898ad4391a9ea96e37e64.js.br -rw-r--r-- 1 nginx nginx 561 Oct 16 14:55 autoptimize_snippet_c2940304f2c898ad4391a9ea96e37e64.js.gz -rw-r--r-- 1 nginx nginx 197 Oct 16 14:55 autoptimize_snippet_c5935bade23936a28a1b0f0eacd59912.js -rw-r--r-- 1 nginx nginx 145 Oct 16 14:55 autoptimize_snippet_c5935bade23936a28a1b0f0eacd59912.js.br -rw-r--r-- 1 nginx nginx 176 Oct 16 14:55 autoptimize_snippet_c5935bade23936a28a1b0f0eacd59912.js.gz -rw-r--r-- 1 nginx nginx 7.9K Oct 16 14:55 autoptimize_snippet_d0c2c0d7e37652e66657c8c8d6376442.js -rw-r--r-- 1 nginx nginx 2.2K Oct 16 14:55 autoptimize_snippet_d0c2c0d7e37652e66657c8c8d6376442.js.br -rw-r--r-- 1 nginx nginx 2.5K Oct 16 14:55 autoptimize_snippet_d0c2c0d7e37652e66657c8c8d6376442.js.gz -rw-r--r-- 1 nginx nginx 189 Jun 26 22:11 index.html

testing with Centmin Mod Nginx with ngx_brotli nginx module enabled

nginx -V nginx version: nginx/1.15.5 (161018-150231) built by gcc 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC) built with OpenSSL 1.1.1 11 Sep 2018 TLS SNI support enabled

onfigure arguments: --with-ld-opt='-Wl,-E -L/usr/local/zlib-cf/lib -L/usr/local/lib -ljemalloc -Wl,-z,relro -Wl,-rpath,/usr/local/zlib-cf/lib:/usr/local/lib' --with-cc-opt='-I/usr/local/zlib-cf/include -I/usr/local/include -m64 -march=native -g -O3 -fstack-protector-strong -flto -fuse-ld=gold --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wimplicit-fallthrough=0 -fcode-hoisting -Wp,-D_FORTIFY_SOURCE=2 -Wno-deprecated-declarations -gsplit-dwarf' --sbin-path=/usr/local/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --build=161018-150231 --with-compat --with-http_stub_status_module --with-http_secure_link_module --with-libatomic --with-http_gzip_static_module --add-dynamic-module=../ngx_brotli --with-http_sub_module --with-http_addition_module --with-http_image_filter_module=dynamic --with-http_geoip_module --with-stream_geoip_module --with-stream_realip_module --with-stream_ssl_preread_module --with-threads --with-stream=dynamic --with-stream_ssl_module --with-http_realip_module --add-dynamic-module=../ngx-fancyindex-0.4.2 --add-module=../ngx_cache_purge-2.5 --add-dynamic-module=../ngx_devel_kit-0.3.0 --add-dynamic-module=../set-misc-nginx-module-0.32 --add-dynamic-module=../echo-nginx-module-0.61 --add-module=../redis2-nginx-module-0.15 --add-module=../ngx_http_redis-0.3.7 --add-module=../memc-nginx-module-0.18 --add-module=../srcache-nginx-module-0.31 --add-dynamic-module=../headers-more-nginx-module-0.33 --with-pcre-jit --with-http_ssl_module --with-http_v2_module --with-openssl=../openssl-1.1.1 --with-openssl-opt='enable-ec_nistp_64_gcc_128 enable-tls1_3'

matching up file sizes on disk for .br or .gz version for wp-content/cache/autoptimize/css/autoptimize_f735042a33273526fb043c5a87f019d8.css

ls -lah wp-content/cache/autoptimize/css/autoptimize_f735042a33273526fb043c5a87f019d8.css* -rw-r--r-- 1 nginx nginx 48K Oct 16 14:55 wp-content/cache/autoptimize/css/autoptimize_f735042a33273526fb043c5a87f019d8.css -rw-r--r-- 1 nginx nginx 6.6K Oct 16 14:55 wp-content/cache/autoptimize/css/autoptimize_f735042a33273526fb043c5a87f019d8.css.br -rw-r--r-- 1 nginx nginx 7.6K Oct 16 14:55 wp-content/cache/autoptimize/css/autoptimize_f735042a33273526fb043c5a87f019d8.css.gz

via curl header checks

uncompressed

curl -I https://$domain/wp-content/cache/autoptimize/css/autoptimize_f735042a33273526fb043c5a87f019d8.css HTTP/1.1 200 OK Date: Tue, 16 Oct 2018 15:13:08 GMT Content-Type: text/css Content-Length: 48767 Last-Modified: Tue, 16 Oct 2018 14:55:58 GMT Connection: keep-alive Vary: Accept-Encoding ETag: "5bc5fbfe-be7f" Server: nginx centminmod X-Powered-By: centminmod Expires: Thu, 15 Nov 2018 15:13:08 GMT Cache-Control: max-age=2592000 Access-Control-Allow-Origin: * Cache-Control: public, must-revalidate, proxy-revalidate, immutable, stale-while-revalidate=86400, stale-if-error=604800 Accept-Ranges: bytes

gzip

curl -I -H "Accept-Encoding: gzip" https://$domain/wp-content/cache/autoptimize/css/autoptimize_f735042a33273526fb043c5a87f019d8.css HTTP/1.1 200 OK Date: Tue, 16 Oct 2018 15:13:55 GMT Content-Type: text/css Content-Length: 7741 Last-Modified: Tue, 16 Oct 2018 14:55:58 GMT Connection: keep-alive Vary: Accept-Encoding ETag: "5bc5fbfe-1e3d" Content-Encoding: gzip Server: nginx centminmod X-Powered-By: centminmod Expires: Thu, 15 Nov 2018 15:13:55 GMT Cache-Control: max-age=2592000 Access-Control-Allow-Origin: * Cache-Control: public, must-revalidate, proxy-revalidate, immutable, stale-while-revalidate=86400, stale-if-error=604800

brotli

curl -I -H "Accept-Encoding: br" https://$domain/wp-content/cache/autoptimize/css/autoptimize_f735042a33273526fb043c5a87f019d8.css HTTP/1.1 200 OK Date: Tue, 16 Oct 2018 15:15:32 GMT Content-Type: text/css Content-Length: 6733 Last-Modified: Tue, 16 Oct 2018 14:55:58 GMT Connection: keep-alive Vary: Accept-Encoding ETag: "5bc5fbfe-1a4d" Content-Encoding: br Server: nginx centminmod X-Powered-By: centminmod Expires: Thu, 15 Nov 2018 15:15:32 GMT Cache-Control: max-age=2592000 Access-Control-Allow-Origin: * Cache-Control: public, must-revalidate, proxy-revalidate, immutable, stale-while-revalidate=86400, stale-if-error=604800

Looks good so far @futtta https://github.com/futtta 👍

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/centminmod/autoptimize-gzip/issues/2#issuecomment-430279946, or mute the thread https://github.com/notifications/unsubscribe-auth/AALEMZ8a6mx_tkjzncFlC-og_-y8egvyks5ulflWgaJpZM4Xdnnv .

centminmod commented 5 years ago

ok will do this mod on a live wordpress site and run it a few days first :)

ghost commented 5 years ago

Has this now been added to AO proper?

futtta commented 5 years ago

@MartyD23 no :)

@centminmod how is this performing "in the wild"? :)

centminmod commented 5 years ago

@futtta it's been doing ok - no critical issues so far :)

pre-compress brotli css/js + nginx http/2 https with brotli + the right cpu i.e. Intel Skylake and right nginx compiler = awesome speed boost compared to nginx and gzip eventually https://community.centminmod.com/threads/testing-gcc-8-clang-5-6-7-compiler-for-centmin-mod-nginx-php-fpm.13726/#post-70527

below HTTP/2 HTTPS h2load benchmarks are with ecdsa ssl ciphers br = brotli and gzip for on the fly compression

nginx-h2load-ecdsa256-bit-01

Unfortunately been busy so haven't gotten round to more wordpress + autoptimize + pre-compress gzip vs brotli testing as yet :)