Join the community today
Become a Member

Wordpress My first Wordpress Autoptimize Gzip Companion Plugin !

Discussion in 'Blogs & CMS usage' started by eva2000, Jul 19, 2018.

  1. eva2000

    eva2000 Administrator Staff Member

    53,217
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,650
    Local Time:
    1:44 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+

    Autoptimize Gzip Companion Wordpress Plugin



    When I first set out to do benchmark comparisons against a Wordpress OceanWP themed site, I didn't realise I would be creating my first ever Wordpress plugin :) Autoptimize by default only minifies and combines CSS and JS files. It doesn't do any pre-gzip compression of those optimised files.

    I asked Frank Goosens the author of Autoptimize if that was possible and he pointed me to an Autoptimize API hook to be able to add an add_filter to enable pre-gzip compression of optimised files. I could hack the Wordpress function.php to add the add_filter or create my own Wordpress plugin for this. Never created a Wordpress plugin, but thought I'd give it a go and so Autoptimize Gzip Wordpress plugin was born https://github.com/centminmod/autoptimize-gzip :D

    wp-autotpimize-gzip-plugin-01.png


    End result is with Autoptimize Gzip Wordpress plugin activated, Autoptimize CSS/JS files have pre-gzip compressed versions which are automatically served since Centmin Mod Nginx is configured with gzip_static directive enabled out of the box :D

    Code (Text):
    ls -lah wp-content/cache/autoptimize/{css,js}
    wp-content/cache/autoptimize/css:
    total 876K
    drwxr-sr-x 2 nginx nginx 4.0K Jul 18 13:39 .
    drwxr-sr-x 4 nginx nginx   58 Jul 18 13:39 ..
    -rw-r--r-- 1 nginx nginx 360K Jul 18 13:39 autoptimize_45f52bb04c1484bf44abe6a7b9acbc26.css
    -rw-r--r-- 1 nginx nginx  57K Jul 18 13:39 autoptimize_45f52bb04c1484bf44abe6a7b9acbc26.css.gz
    -rw-r--r-- 1 nginx nginx 6.2K Jul 18 13:39 autoptimize_snippet_02186534fc2cb75d30ffeb4e4060f935.css
    -rw-r--r-- 1 nginx nginx 1.3K Jul 18 13:39 autoptimize_snippet_02186534fc2cb75d30ffeb4e4060f935.css.gz
    -rw-r--r-- 1 nginx nginx  12K Jul 18 13:39 autoptimize_snippet_1eb49ea21489172bd56a487a10870e2a.css
    -rw-r--r-- 1 nginx nginx 2.5K Jul 18 13:39 autoptimize_snippet_1eb49ea21489172bd56a487a10870e2a.css.gz
    -rw-r--r-- 1 nginx nginx  19K Jul 18 13:39 autoptimize_snippet_4601ba55044413706c2022cb6c1c3d05.css
    -rw-r--r-- 1 nginx nginx 2.5K Jul 18 13:39 autoptimize_snippet_4601ba55044413706c2022cb6c1c3d05.css.gz
    -rw-r--r-- 1 nginx nginx  11K Jul 18 13:39 autoptimize_snippet_4b467d2937419b5d1798dbbb1152cf0f.css
    -rw-r--r-- 1 nginx nginx 2.4K Jul 18 13:39 autoptimize_snippet_4b467d2937419b5d1798dbbb1152cf0f.css.gz
    -rw-r--r-- 1 nginx nginx  36K Jul 18 13:39 autoptimize_snippet_54e3c9ede8364f0230bbf0b126573f48.css
    -rw-r--r-- 1 nginx nginx 5.5K Jul 18 13:39 autoptimize_snippet_54e3c9ede8364f0230bbf0b126573f48.css.gz
    -rw-r--r-- 1 nginx nginx 154K Jul 18 13:39 autoptimize_snippet_7a3d1e443c9b01e31baba6cf73df2c51.css
    -rw-r--r-- 1 nginx nginx  23K Jul 18 13:39 autoptimize_snippet_7a3d1e443c9b01e31baba6cf73df2c51.css.gz
    -rw-r--r-- 1 nginx nginx  81K Jul 18 13:39 autoptimize_snippet_87a799a52deae21568519f4f59699fa6.css
    -rw-r--r-- 1 nginx nginx  12K Jul 18 13:39 autoptimize_snippet_87a799a52deae21568519f4f59699fa6.css.gz
    -rw-r--r-- 1 nginx nginx  31K Jul 18 13:39 autoptimize_snippet_be209e54c9b6a4495155c3a9a88d3d36.css
    -rw-r--r-- 1 nginx nginx 6.9K Jul 18 13:39 autoptimize_snippet_be209e54c9b6a4495155c3a9a88d3d36.css.gz
    -rw-r--r-- 1 nginx nginx 1.6K Jul 18 13:39 autoptimize_snippet_bf9646dfeee6767c35fd21dd649bfc3e.css
    -rw-r--r-- 1 nginx nginx  675 Jul 18 13:39 autoptimize_snippet_bf9646dfeee6767c35fd21dd649bfc3e.css.gz
    -rw-r--r-- 1 nginx nginx 5.1K Jul 18 13:39 autoptimize_snippet_c94c9f38516a99b1f2ab4bfb5da9840d.css
    -rw-r--r-- 1 nginx nginx 1.6K Jul 18 13:39 autoptimize_snippet_c94c9f38516a99b1f2ab4bfb5da9840d.css.gz
    -rw-r--r-- 1 nginx nginx  189 Jul 16 18:48 index.html
    
    wp-content/cache/autoptimize/js:
    total 952K
    drwxr-sr-x 2 nginx nginx 4.0K Jul 18 13:39 .
    drwxr-sr-x 4 nginx nginx   58 Jul 18 13:39 ..
    -rw-r--r-- 1 nginx nginx 347K Jul 18 13:39 autoptimize_1b323efed247e12911173c54e22b3a4e.js
    -rw-r--r-- 1 nginx nginx  93K Jul 18 13:39 autoptimize_1b323efed247e12911173c54e22b3a4e.js.gz
    -rw-r--r-- 1 nginx nginx  20K Jul 18 13:39 autoptimize_snippet_14b16c0a613dccf79fea485ec09717a1.js
    -rw-r--r-- 1 nginx nginx 7.0K Jul 18 13:39 autoptimize_snippet_14b16c0a613dccf79fea485ec09717a1.js.gz
    -rw-r--r-- 1 nginx nginx 6.4K Jul 18 13:39 autoptimize_snippet_1c4a13edec1958817e83433aeaa42f62.js
    -rw-r--r-- 1 nginx nginx 2.6K Jul 18 13:39 autoptimize_snippet_1c4a13edec1958817e83433aeaa42f62.js.gz
    -rw-r--r-- 1 nginx nginx  12K Jul 18 13:39 autoptimize_snippet_3819c3569da71daec283a75483735f7e.js
    -rw-r--r-- 1 nginx nginx 3.0K Jul 18 13:39 autoptimize_snippet_3819c3569da71daec283a75483735f7e.js.gz
    -rw-r--r-- 1 nginx nginx  193 Jul 18 13:39 autoptimize_snippet_4ec3b19ffe467100c29c66bcc97ebc42.js
    -rw-r--r-- 1 nginx nginx  173 Jul 18 13:39 autoptimize_snippet_4ec3b19ffe467100c29c66bcc97ebc42.js.gz
    -rw-r--r-- 1 nginx nginx 1.2K Jul 18 13:39 autoptimize_snippet_4fb38de1728cf7f23aa8b49d85bddde5.js
    -rw-r--r-- 1 nginx nginx  606 Jul 18 13:39 autoptimize_snippet_4fb38de1728cf7f23aa8b49d85bddde5.js.gz
    -rw-r--r-- 1 nginx nginx 1014 Jul 18 13:39 autoptimize_snippet_7567776c328ea6a29916d6cbb521bed6.js
    -rw-r--r-- 1 nginx nginx  518 Jul 18 13:39 autoptimize_snippet_7567776c328ea6a29916d6cbb521bed6.js.gz
    -rw-r--r-- 1 nginx nginx 121K Jul 18 13:39 autoptimize_snippet_9234b7a231cefc9a6ca4299c8c538897.js
    -rw-r--r-- 1 nginx nginx  32K Jul 18 13:39 autoptimize_snippet_9234b7a231cefc9a6ca4299c8c538897.js.gz
    -rw-r--r-- 1 nginx nginx 9.9K Jul 18 13:39 autoptimize_snippet_af02609a4853bf8aa780e7614f25a8b5.js
    -rw-r--r-- 1 nginx nginx 3.3K Jul 18 13:39 autoptimize_snippet_af02609a4853bf8aa780e7614f25a8b5.js.gz
    -rw-r--r-- 1 nginx nginx  11K Jul 18 13:39 autoptimize_snippet_bb483d9d967a457fc9f0a1505bd958e7.js
    -rw-r--r-- 1 nginx nginx 3.3K Jul 18 13:39 autoptimize_snippet_bb483d9d967a457fc9f0a1505bd958e7.js.gz
    -rw-r--r-- 1 nginx nginx 1.3K Jul 18 13:39 autoptimize_snippet_c2940304f2c898ad4391a9ea96e37e64.js
    -rw-r--r-- 1 nginx nginx  561 Jul 18 13:39 autoptimize_snippet_c2940304f2c898ad4391a9ea96e37e64.js.gz
    -rw-r--r-- 1 nginx nginx  197 Jul 18 13:39 autoptimize_snippet_c5935bade23936a28a1b0f0eacd59912.js
    -rw-r--r-- 1 nginx nginx  176 Jul 18 13:39 autoptimize_snippet_c5935bade23936a28a1b0f0eacd59912.js.gz
    -rw-r--r-- 1 nginx nginx 120K Jul 18 13:39 autoptimize_snippet_cf0aff8f63c5c87968954baa1a1347c3.js
    -rw-r--r-- 1 nginx nginx  31K Jul 18 13:39 autoptimize_snippet_cf0aff8f63c5c87968954baa1a1347c3.js.gz
    -rw-r--r-- 1 nginx nginx 7.9K Jul 18 13:39 autoptimize_snippet_d0c2c0d7e37652e66657c8c8d6376442.js
    -rw-r--r-- 1 nginx nginx 2.5K Jul 18 13:39 autoptimize_snippet_d0c2c0d7e37652e66657c8c8d6376442.js.gz
    -rw-r--r-- 1 nginx nginx  37K Jul 18 13:39 autoptimize_snippet_eb8f10414a9287740be91bdc1d5951aa.js
    -rw-r--r-- 1 nginx nginx  11K Jul 18 13:39 autoptimize_snippet_eb8f10414a9287740be91bdc1d5951aa.js.gz
    -rw-r--r-- 1 nginx nginx  189 Jul 16 18:48 index.html
    


    Webpagetest improvements can clearly been seen with pre-gzipped version rendering much early than non-gzipped version

    wp-autotpimize-gzip-plugin-02.png
    wp-autotpimize-gzip-plugin-03.png

    Before pre-gzip
    • js 345,068 bytes
    • css 78,977 bytes
    After pre-gzip
    • js 342,573 bytes
    • css 71,210 bytes
    No Autoptimize pre-gzip
    Code (Text):
    h2load -t1 -H 'Accept-Encoding: gzip' -c500 -n10000 $domain
    starting benchmark...
    spawning thread #0: 500 total client(s). 10000 total requests
    TLS Protocol: TLSv1.2
    Cipher: ECDHE-RSA-AES128-GCM-SHA256
    Server Temp Key: ECDH P-256 256 bits
    Application protocol: h2
    progress: 10% done
    progress: 20% done
    progress: 30% done
    progress: 40% done
    progress: 50% done
    progress: 60% done
    progress: 70% done
    progress: 80% done
    progress: 90% done
    progress: 100% done
    
    finished in 2.31s, 4322.29 req/s, 29.90MB/s
    requests: 10000 total, 10000 started, 10000 done, 10000 succeeded, 0 failed, 0 errored, 0 timeout
    status codes: 10000 2xx, 0 3xx, 0 4xx, 0 5xx
    traffic: 69.18MB (72545000) total, 1.55MB (1620500) headers (space savings 32.76%), 67.44MB (70720000) data
                         min         max         mean         sd        +/- sd
    time for request:     6.77ms    141.20ms     73.63ms     15.36ms    95.00%
    time for connect:    20.70ms    866.33ms    415.80ms    235.22ms    60.00%
    time to 1st byte:   867.07ms       1.02s    919.81ms     37.34ms    75.40%
    req/s           :       8.70        9.04        8.86        0.10    54.60%
    

    Autoptimize Pre-gzipped - notice the TTFB average and max times much lower
    Code (Text):
    h2load -t1 -H 'Accept-Encoding: gzip' -c500 -n10000 $domain2
    starting benchmark...
    spawning thread #0: 500 total client(s). 10000 total requests
    TLS Protocol: TLSv1.2
    Cipher: ECDHE-ECDSA-AES128-GCM-SHA256
    Server Temp Key: ECDH P-256 256 bits
    Application protocol: h2
    progress: 10% done
    progress: 20% done
    progress: 30% done
    progress: 40% done
    progress: 50% done
    progress: 60% done
    progress: 70% done
    progress: 80% done
    progress: 90% done
    progress: 100% done
    
    finished in 2.17s, 4607.10 req/s, 31.87MB/s
    requests: 10000 total, 10000 started, 10000 done, 10000 succeeded, 0 failed, 0 errored, 0 timeout
    status codes: 10000 2xx, 0 3xx, 0 4xx, 0 5xx
    traffic: 69.17MB (72535000) total, 2.01MB (2110500) headers (space savings 29.41%), 66.97MB (70220000) data
                         min         max         mean         sd        +/- sd
    time for request:     6.55ms    119.32ms     76.38ms     11.57ms    91.53%
    time for connect:    27.46ms    637.04ms    316.80ms    161.60ms    61.80%
    time to 1st byte:   637.77ms    803.64ms    695.66ms     41.00ms    75.80%
    req/s           :       9.28        9.73        9.49        0.13    55.00%
    

    To further verify the benefit of pre-gzipped CSS/JS files check nghttp2 HTTP/2 HTTPS statistics tests which will report the processing time for each asset i.e. autoptimize css and js combined files

    No Autoptimize pre-gzip
    Code (Text):
    nghttp -nas $domain
    ***** Statistics *****
    
    Request timing:
      responseEnd: the  time  when  last  byte of  response  was  received
                   relative to connectEnd
     requestStart: the time  just before  first byte  of request  was sent
                   relative  to connectEnd.   If  '*' is  shown, this  was
                   pushed by server.
          process: responseEnd - requestStart
             code: HTTP status code
             size: number  of  bytes  received as  response  body  without
                   inflation.
              URI: request URI
    
    see http://www.w3.org/TR/resource-timing/#processing-model
    
    sorted by 'complete'
    
    id  responseEnd requestStart  process code size request path
     13     +3.19ms       +170us   3.02ms  200   6K /
     15    +23.31ms      +3.21ms  20.10ms  200  63K /wp-content/cache/autoptimize/css/autoptimize_f48388bb1367de80ac97d16fe4b16efb.css
     17    +23.46ms      +3.21ms  20.25ms  200   4K /wp-content/uploads/elementor/css/post-2.css
     19    +24.35ms      +3.21ms  21.14ms  200  33K /wp-includes/js/jquery/jquery.js
     21    +26.30ms      +3.21ms  23.09ms  200  612 /wp-content/uploads/2016/10/normal-logo.png
     23    +26.33ms      +3.21ms  23.11ms  200  14K /wp-content/uploads/2016/10/package1.jpg
     37    +27.14ms      +3.23ms  23.91ms  200  93K /wp-content/cache/autoptimize/js/autoptimize_9d054a7e1b8e68c3f2029d6d4b0599a5.js
     29    +27.36ms      +3.22ms  24.14ms  200  17K /wp-content/uploads/2016/10/package6.jpg
     33    +27.68ms      +3.22ms  24.46ms  200  13K /wp-content/uploads/2016/10/package5.jpg
     35    +27.69ms      +3.23ms  24.46ms  200   2K /wp-content/uploads/2016/10/testi.jpg
     27    +27.91ms      +3.22ms  24.69ms  200  19K /wp-content/uploads/2016/10/package2.jpg
     31    +27.92ms      +3.22ms  24.70ms  200  17K /wp-content/uploads/2016/10/package3.jpg
     25    +27.92ms      +3.22ms  24.71ms  200  27K /wp-content/uploads/2016/10/package4.jpg
    

    Autoptimize Pre-gzipped notice process time and reported size of pre-gzipped autoptimize css and js files are much lower. CSS and JS file process time without pre-gzip is 20.10ms and 23.91ms respectively while sizes where 63KB and 93KB respectively. While with pre-gzip times for CSS and JS file process time were 7.72ms and 13.44ms respectively with sizes reported at 56KB and 92KB.
    Code (Text):
    nghttp -nas $domain2
    ***** Statistics *****
    
    Request timing:
      responseEnd: the  time  when  last  byte of  response  was  received
                   relative to connectEnd
     requestStart: the time  just before  first byte  of request  was sent
                   relative  to connectEnd.   If  '*' is  shown, this  was
                   pushed by server.
          process: responseEnd - requestStart
             code: HTTP status code
             size: number  of  bytes  received as  response  body  without
                   inflation.
              URI: request URI
    
    see http://www.w3.org/TR/resource-timing/#processing-model
    
    sorted by 'complete'
    
    id  responseEnd requestStart  process code size request path
     13     +3.42ms       +150us   3.27ms  200   6K /
     15    +11.20ms      +3.47ms   7.72ms  200  56K /wp-content/cache/autoptimize/css/autoptimize_45f52bb04c1484bf44abe6a7b9acbc26.css
     17    +12.01ms      +3.48ms   8.53ms  200   3K /wp-content/uploads/elementor/css/post-2.css
     19    +13.22ms      +3.48ms   9.74ms  200  33K /wp-includes/js/jquery/jquery.js
     21    +15.77ms      +3.48ms  12.29ms  200  636 /wp-content/uploads/2016/10/normal-logo.png
     23    +15.81ms      +3.48ms  12.32ms  200  14K /wp-content/uploads/2016/10/package1.jpg
     37    +16.93ms      +3.49ms  13.44ms  200  92K /wp-content/cache/autoptimize/js/autoptimize_1b323efed247e12911173c54e22b3a4e.js
     29    +17.30ms      +3.49ms  13.81ms  200  17K /wp-content/uploads/2016/10/package6.jpg
     33    +17.69ms      +3.49ms  14.20ms  200  13K /wp-content/uploads/2016/10/package5.jpg
     35    +17.70ms      +3.49ms  14.21ms  200   2K /wp-content/uploads/2016/10/testi.jpg
     25    +17.73ms      +3.48ms  14.25ms  200  27K /wp-content/uploads/2016/10/package4.jpg
     31    +17.93ms      +3.49ms  14.44ms  200  17K /wp-content/uploads/2016/10/package3.jpg
     27    +17.96ms      +3.48ms  14.47ms  200  19K /wp-content/uploads/2016/10/package2.jpg
    


    Edit actually this feature was mentioned in FAQ at Autoptimize :)

    Update: Feb 25, 2019

    Heads up Autoptimize has plans to formally add brotli pre-compression support Create brotli version of cached files by willstocks-tech · Pull Request #237 · futtta/autoptimize which will be enabled when you install my Autoptimize-gzip Wordpress Plugin once added :D

    You will need to be using Centmin Mod 123.09beta01 and enable PHP compression extension support for PHP_BROTLI='y' at least as outlined at https://community.centminmod.com/th...-extensions-by-default-in-123-09beta01.16616/ and ensuring they have Nginx Brotli module enabled via NGXDYNAMIC_BROTLI='y' and NGINX_LIBBROTLI='y' variables prior to Centmin Mod Ngixn recompiles - which will also install Brotli library required to do the actual Brotli compression.

    Update: May 7, 2019

    Added native Autoptimize Gzip companion plugin support into centmin.sh menu option 22 wordpress auto install - details on enabling it outlined at https://community.centminmod.com/th...2-nginx-vhost-routines-in-123-09beta01.17451/
     
    Last edited: Aug 1, 2018
  2. eva2000

    eva2000 Administrator Staff Member

    53,217
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,650
    Local Time:
    1:44 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  3. Mrbo

    Mrbo Member

    113
    7
    18
    Jun 17, 2018
    Ratings:
    +7
    Local Time:
    10:44 PM
    Hi! Thanks for this plugin. Looking forward to try this the coming days after I´ve set up a new server, properly this time. Will get back with feedback soon :)
     
  4. Qu Don

    Qu Don Member

    79
    7
    8
    Aug 21, 2017
    Brooklyn, New York
    Ratings:
    +22
    Local Time:
    11:44 AM
    Does this have to be used independently or does it need Autoptimize plugin installed as well
     
  5. eva2000

    eva2000 Administrator Staff Member

    53,217
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,650
    Local Time:
    1:44 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    It need Autoptimize plugin installed as well
     
  6. eva2000

    eva2000 Administrator Staff Member

    53,217
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,650
    Local Time:
    1:44 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Heads up one user asked about autoptimize doing pre-compressed brotli compressed css/js assets for wordpress installs and seems Frank author of autoptimize shared some untested code alterations which enable pre-compressed brotli assets if brotli php extension was detected/installed. So I tested thise code alteration and so far seems to work. Discussion and instructions at Add brotli static · Issue #2 · centminmod/autoptimize-gzip
    Code (Text):
    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
    Code (Text):
    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
    

    Code (Text):
    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 ^_^
    Code (Text):
    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
    

    matching up file sizes on disk for .br or .gz version for wp-content/cache/autoptimize/css/autoptimize_f735042a33273526fb043c5a87f019d8.css
    Code (Text):
    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
    Code (Text):
    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
    Code (Text):
    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
    Code (Text):
    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
    
     
  7. shevan

    shevan New Member

    13
    2
    3
    Nov 7, 2018
    Ratings:
    +4
    Local Time:
    6:44 PM
    Nginx 15.5
    MariaDB 10
    Thank you. It works great!
     
  8. eva2000

    eva2000 Administrator Staff Member

    53,217
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,650
    Local Time:
    1:44 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Glad to hear my plugin has been useful :)
     
  9. upgrade81

    upgrade81 Member

    290
    17
    18
    Sep 5, 2016
    CH
    Ratings:
    +30
    Local Time:
    5:44 PM
    1.17
    10.3
    fantastic, I try it now.
     
  10. upgrade81

    upgrade81 Member

    290
    17
    18
    Sep 5, 2016
    CH
    Ratings:
    +30
    Local Time:
    5:44 PM
    1.17
    10.3
    tried and everything works!

    the only thing is that it does not create static files concerning brotli compression.
    I followed your procedure to install the php module.
     
  11. eva2000

    eva2000 Administrator Staff Member

    53,217
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,650
    Local Time:
    1:44 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    did you modify autopimize code outlined at Add brotli static · Issue #2 · centminmod/autoptimize-gzip ?
     
  12. Jay Chen

    Jay Chen Active Member

    181
    60
    28
    Sep 10, 2017
    Ratings:
    +116
    Local Time:
    11:44 AM
    Does it make sense to install this plugin when I'm using cloudflare?
    I believe cloudflare compresses the files before storing them.
    So any files serve from cloudflare will be compressed.
     
  13. eva2000

    eva2000 Administrator Staff Member

    53,217
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,650
    Local Time:
    1:44 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yeah don't need this plugin if using Cloudflare in front of your sites
     
  14. upgrade81

    upgrade81 Member

    290
    17
    18
    Sep 5, 2016
    CH
    Ratings:
    +30
    Local Time:
    5:44 PM
    1.17
    10.3
  15. upgrade81

    upgrade81 Member

    290
    17
    18
    Sep 5, 2016
    CH
    Ratings:
    +30
    Local Time:
    5:44 PM
    1.17
    10.3
    I have not yet figured out where this code should be inserted.
    In the function it does not work.

    Code:
    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 ) );
        }
    }
     
  16. eva2000

    eva2000 Administrator Staff Member

    53,217
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,650
    Local Time:
    1:44 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  17. upgrade81

    upgrade81 Member

    290
    17
    18
    Sep 5, 2016
    CH
    Ratings:
    +30
    Local Time:
    5:44 PM
    1.17
    10.3
    Thank you, so if you update the plugin you probably lose the change.
    Good to know.
     
  18. upgrade81

    upgrade81 Member

    290
    17
    18
    Sep 5, 2016
    CH
    Ratings:
    +30
    Local Time:
    5:44 PM
    1.17
    10.3
    inserted below in various ways but does not work, crash wordpress.

    Code:
         if ( false === $this->nogzip ) {
                // We handle gzipping ourselves.
                $file    = 'default.php';
                $phpcode = file_get_contents( AUTOPTIMIZE_PLUGIN_DIR . 'config/' . $file );
                $phpcode = str_replace( array( '%%CONTENT%%', 'exit;' ), array( $mime, '' ), $phpcode );
    
                file_put_contents( $this->cachedir . $this->filename, $phpcode );
                file_put_contents( $this->cachedir . $this->filename . '.none', $data );
            } else {
                // Write code to cache without doing anything else.
                file_put_contents( $this->cachedir . $this->filename, $data );
                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 ) );
                }
            }
        }
    
     
  19. eva2000

    eva2000 Administrator Staff Member

    53,217
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,650
    Local Time:
    1:44 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  20. upgrade81

    upgrade81 Member

    290
    17
    18
    Sep 5, 2016
    CH
    Ratings:
    +30
    Local Time:
    5:44 PM
    1.17
    10.3
    perfect, now everything works.
    however the site by logged in user is slow to respond.
    As a guest, however, it is fast.