[drupal-support] PHP compression and cacheing

Julian Bond julian_bond at voidstar.com
Tue Mar 1 14:18:38 UTC 2005


Dries Buytaert <dries at buytaert.net> Tue, 1 Mar 2005 14:12:38
>This rings a bell -- alas Moshe reported a similar issue.  To date, we 
>haven't been able to reproduce nor fix it. From what I have been told, 
>it is specific to IE <some-version>. More details or investigation 
>would be appreciated.

Just been looking through bootstrap.inc.

- Page data retrieved via ob_get_contents()
- Page data is gzencoded
- gzencoded string saved in table cache
- New request arrives
- If the browser doesn't support gzip, inflate it. Else leave it 
gzipped.
- If it's still gzipped send content encoding header
- print the results.

Now if I have php doing gzip via zlib.output_compression in php.ini, 
that last print is going to be gzip encoded again. *Unless* php 
recognises that the code has already set the content encoding header and 
so passes it through untouched.

So what we could have here is:-
1) A bug in php handling that is missing the fact that the code is 
saying I've already encoded it resulting in double encoding.
2) some combination of the browser saying it can accept gzip, deflate 
when actually it can only accept deflate.
3) Some browsers managing to work out, some times, that a file is double 
encoding and decoding it until they see an <html> statement.

I think I'd recommend leaving everything in plain and letting php 
(zlib.output_compression) or apache (mod_gzip) do the negotiation with 
the browser. Alternatively add an administration switch to 
enable/disable buffering and gzencoding of all output for people who 
don't have access to php.ini or apache. Or a third possibility, put the 
php switch into the .htaccess file. At the moment I think there's at 
least a possibility of double encoding happening.

-- 
Julian Bond Email&MSM: julian.bond at voidstar.com
Webmaster:                 http://www.ecademy.com/
Personal WebLog:          http://www.voidstar.com/
M: +44 (0)77 5907 2173      T: +44 (0)192 0412 433
S: callto://julian.bond/



More information about the drupal-support mailing list