This page is no longer updated - please visit http://ghostwire.com Thank you!
 

« PHPObject »
An Opensource Alternative to Flash Remoting
Current Release
Readme
Notes
Journal
Archives

Notes
Wednesday April 23, 2003

Using zlib compression

In a pre-v1.0 version, I had experimented with the gzcompress function in PHP to compress the data sent back to the client. Using zlib compression, the message transferred back to the client is effectively 'binary' and smaller.

It apparently worked if I view the movie in a browser. This is because when you run the movie within a browser, (compressed) data is first received by the browser, and Flash pick up the (deflated) file from the browser's cache.

However, I finally decided not to include any compression into the PHPObject Gateway. First, not everyone has zlib compiled with PHP. Second, I was told that even if you have zlib compiled, it is best to set transparent zlib compression using zlib_compression = On in the php.ini configuration file. Switching this on means that PHP scripts will gz compress their output if the HTTP_ACCEPT_ENCODING was detected to be 'gzip, deflate'. Flash standalone player does not accept gzip encoded data (it will send an empty HTTP_ACCEPT_ENCODING header to PHP, and PHP will not compress the output). Flash plugin in browsers supporting zlib compression will send the appropriate header and PHP will return compressed data.

If you decide to use zlib compression, but want to do it dynamically using the gz functions in PHP instead of setting php.ini, please remember to check the HTTP_ACCEPT_ENCODING before sending compressed data (you will have to modify the gateway yourself, because it is unlikely that any future release of PHPObject will have that feature).

You can give the above a try and see if your message size is reduced. Not only when using PHPObject, but in your other PHP work as well. I am not sure if compressing always means faster results, because if on broadband, the download may be faster than the time taken to compress the data!???

Posted by sunny at April 23, 2003 10:52 PM

 

Comments

Hi Sunny,

Think you've done the right thing there...seems to be a few horror stories about zlib. And if you're using Apache as a server, it can be done with mod_gzip (which kinda reduces the benefits of AMF as well).

Anyway, good luck with your project!

peace
si

Posted by: si at April 24, 2003 02:05 PM

 


Zones



Forums