Nginx and Cache Enabler's Pre-compression causing content decoding errors
-
Given a fairly standard Nginx configuration for WordPress, I’m encountering problems when enabling the “Pre-compression of cached pages.” option in Cache Enabler. Here’s a part of the Nginx config:
location / {
try_files $uri $uri/ /index.php$is_args$args;
}This, combined with “Pre-compression of cached pages.” in Cache Enabler will give a content decoding error (but only from the second time the page is loaded, the first time the page still displays correctly). Surprisingly, this happens even when I disable gzip in Nginx altogether. For example, Here are the headers for the first two requests on the same page in WordPress:
1st Page Load (this one displays correctly)
HTTP/1.1 200 OK
Server: nginx/1.10.0 (Ubuntu)
Date: Wed, 18 May 2016 19:35:57 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive2nd Page Load (ERR_CONTENT_DECODING_FAILED in Chrome)
HTTP/1.1 200 OK
Server: nginx/1.10.0 (Ubuntu)
Date: Wed, 18 May 2016 19:35:59 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Cache-Handler: php
Content-Encoding: gzipPerhaps I’m seeing the same thing described here: https://www.ads-software.com/support/topic/difficult-problem-with-double-content-encoding-gzip-content-encoding-gzip?replies=2
I’m guessing the issue here is indeed that the content is gzip encoded twice, and even when gzip is disabled in the Nginx config file. I can confirm that the fix mentioned in that thread for WP Super Cache works. So I imagine that, if the same could be done for Cache Enabler, it would probably also resolve the problem. In other words, I’d need to be able to tell Cache Enabler to only create the .gz file, but not actually send gzipped content to Nginx.
I’m interested in hearing if this problem can be reproduced, because I encountered this on two different configurations and with both WP Super Cache and Cache Enabler. If you’re wondering why I’m even bothering with the pre-compression from Cache Enabler and don’t just let Nginx handle gzipping everything: I’d like to make use of the gzip_static option in Nginx, so that it doesn’t need to compress the files on each and every request.
- The topic ‘Nginx and Cache Enabler's Pre-compression causing content decoding errors’ is closed to new replies.