homepage Welcome to WebmasterWorld Guest from 54.161.166.171
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Content-Encoding is not set in response when using php compression
"php_value zlib.output_compression On" in .htaccess doesn't work
referer




msg:1305228
 8:32 am on Feb 7, 2006 (gmt 0)

I enabled automatic gzip compression with the following lines in .htaccess:

php_value zlib.output_compression On
php_value zlib.output_compression_level 5

The problem is that the Content-Encoding header does not get set at all in the response. Therefore, a browser that advertises itself as supporting gzip compression (Accept-Encoding: gzip,deflate) receives
compressed content but does not know it is compressed.

If I manually add the following to my script:

header("Content-Encoding: gzip");

... it then works.

I'm using PHP Version 4.4.2 with the following Configure Command

'./configure' '--with-apache=../apache_1.3.34' '--with-openssl'
'--with-gd' '--with-mysql' '--enable-trans-sid' '--enable-track-vars'
'--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-zlib=/usr'
'--enable-mbstring' '--enable-ftp' '--enable-exif'
'--with-freetype-dir=/usr/local' '--with-pspell=/usr/local'

Zlib settings:
ZLib Support enabled
Compiled Version 1.2.2
Linked Version 1.2.2

Any ideas of what might be causing this? Is it a php error?

 

eeek




msg:1305229
 11:28 pm on Feb 8, 2006 (gmt 0)

Do you have any flush() calls in your script? Output buffering?

referer




msg:1305230
 6:53 am on Feb 9, 2006 (gmt 0)

Nope. Nothing.

AlexK




msg:1305231
 7:23 am on Feb 9, 2006 (gmt 0)

Have a look at this Content-Negotiation Class [webmasterworld.com] (compression is included by default). Some support is at this and following pages [webmasterworld.com]. That will both solve your problem, and also give you load-balanced compression.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved