PHP Compression with GZip: Content Encoding Error
Symptoms:
Site returns Content Encoding Error or similar error
Firefox:
Content Encoding Error
The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.
* Please contact the web site owners to inform them of this problem.
Chrome:
This web page is not available.
The web page at http:/domain.tld/path/to/file.ext might be temporarily down or it may have moved permanently to a new web address. More information on this error
Below is the original error message
Safari:
Safari can’t open the page.
Safari can’t open the page “http://domain.tld/path/to/file.ext;. The error is: “cannot decode raw data” (CFURLErrorDomain:-1015) Please choose Help > Report Bugs to Apple, note the error number, and describe what you did before you saw this message.
Internet Explorer 7:
IE doesn not return an error that explicitly mention content encoding or compression
Opera:
Opera does not return an error, instead it displays the page content, partially compressed. Error messages will be human readable. Compressed data appears as garbage.
Example:
����y�ŝ^�Z� stnXΨW ��)���
Cause:
GZip can be enabled on the server for more efficient page delivery. On occasion, PHP errors my be output that are not compressed with the rest of the page content. When this occurs, some browsers fail to identify the uncompressed error message and thus cannot output the page.
Solution:
Opera can be used to view the uncompressed data and interpret the error message.
Alternatively, the linux command line
wget
can be used to get and view the output of the file:
wget --header "Accept-Encoding: gzip,deflate" http://domain.tld/path/to/file.ext
If the page uses basic authentication:
wget --header "Accept-Encoding: gzip,deflate" http://user:password@domain.tld/path/to/file.ext
You can then use your preferred text editor to view the file you have just downloaded and interpret the error.
Finally you will need to resolve whatever caused the PHP error in the first place.
Conclusion:
Opera rocks. End transmission.
(…from the one armed scissor)