• Using WP 4.1 and wp-super-cache 1.4.2

    I am having a difficult problem eliminating a special case of double encoding by nginx of supercache’s already gzipped output when legacy cache files are served.

    Most modern browsers figure out this problem and properly double decode the situation but Safari does not.

    I am able to reproduce this problem consistently on mobile safari and the last Windows desktop Safari 5

    Basically take any logged out user and they will see regular wordpress posts fine.

    Then add a query string to any post url the the problem will happen.

    example.com/blah-blah?abc=123

    Content-Type	 text/html; charset=UTF-8
     Transfer-Encoding	 chunked
     Connection	 keep-alive
     Content-Encoding	 gzip
     Content-Encoding	 gzip
     Vary	 Accept-Encoding, Cookie
     WP-Super-Cache	 Served legacy cache file

    Note you need a special header viewer to see the double gzip header because some browsers will merge them entirely or show gzip, gzip instead.

    What is happening is wp-super-cache is dumping the raw gzipped cache file though PHP and adding a content-encoding header but then NGINX is also configured to GZIP all output from PHP backend.

    So it gets double gzipped.

    One harsh way to fix this would be to disable all gzip in wp-super-cache which I do not want to do, since nginx can easily serve the already gzipped files.

    I’ve researched nginx and there does not appear to be any way to disable the gzip if the backend already has a header set.

    Which means the problem has to be fixed inside the plugin, somewhere in phase1 or phase2

    Thanks for any help

    https://wordpress.org/plugins/wp-super-cache/

Viewing 1 replies (of 1 total)
  • Thread Starter _ck_

    (@_ck_)

    Okay figured out a simple workaround if anyone runs into this in the future

    in phase1 just return false when testing gzip_accepted

    function gzip_accepted(){ return false;

    This way supercache still makes the .gz files for direct serving via nginx but will use the non-gzip version of the file when it falls through to legacy mode when a url query is present. Then nginx will still gzip the output properly.

Viewing 1 replies (of 1 total)

The topic ‘difficult problem with double "Content-Encoding: gzip" "Content-Encoding: gzip"’ is closed to new replies.