Thursday, February 17, 2005

PHP Oddity

Discovered a little oddity with PHP and Firefox. In my root .htaccess file I have:

php_flag zlib.output_compression On
php_value zlib.output_compression_level 9

This causes all PHP files to be compressed, if the user agent accepts compression.

My error page is also a PHP script, mostly to trap the referring URL and include that in the page. Entirely by accident tonight I discovered that the error page was being returned as complete gibberish to Firefox. My guess is that Firefox was receiving the error page as a compressed page, but was not uncompressing it.

A little investigation with the Live HTTP Headers extension revealed that the page was being served with Transfer-encoding: chunked instead of Content-encoding: gzip. I don't know where to look to debug further, but did manage to override the behaviour on the server side by adding:

php_flag zlib.output_compression Off

to the .htaccess for the directory containing my error pages.

e.p.c. posted this at 22:33 GMT on 17-Feb-2005 .

Slightly acerbic and eccentric dog walker who masquerades as a web developer and occasional CTO.

Spent five years running the technology side of the circus known as www.ibm.com.

More about me here.

Archives