Re: [PHP] HTTP Compression
On Fri, Jun 14, 2002 at 08:58:29AM +0100, Webmaster do Aborla.net wrote: I would like to know how can I compress the output of PHP through Zlib. You mean like: http://www.php.net/manual/en/function.ob-gzhandler.php -- Daniel Tryba -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTTP compression
I've just started experimenting with ob_start("ob_gzhandler") a bit, and I have found that if any output is generated before ob_start() is called, nothing at all gets compressed; if ob_start() is called before any output, everything is compressed. Is this the case, I mean, is this "by design" ? Yes, it wouldn't really work any other way. You can't mix non-compressed and compressed in the same request. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] HTTP compression
Rasmus, Thanks for the clarification; it seems obvious, too, that mixing compressed and non compressed content would be quite difficult to implement; at least it would partially compromise the speed/size gain because of added protocol overhead. Now, imagining that we have enabled compression by calling ob_start("ob_gzhandler"), what happens for a document that contains something along these lines: !-- snip -- ... ? // Enable HTTP compression ob_start("ob_gzhandler"); // PHP content $content = "This is some content."; ? divThis is a normal HTML section/div ? // PHP content continues $content .= "And the rest of it."; echo $content; ? ... !-- snip -- In this particular case, what would be compressed ? As far as I have understood, nothing at all, because some part of the output is not "passing through" PHP, right ? -Message d'origine- De : Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Envoye : dimanche 4 fevrier 2001 14:34 A : Alain Fontaine Cc : [EMAIL PROTECTED] Objet : Re: [PHP] HTTP compression I've just started experimenting with ob_start("ob_gzhandler") a bit, and I have found that if any output is generated before ob_start() is called, nothing at all gets compressed; if ob_start() is called before any output, everything is compressed. Is this the case, I mean, is this "by design" ? Yes, it wouldn't really work any other way. You can't mix non-compressed and compressed in the same request. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] HTTP compression
Alain, When PHP parses a file, it treats the stuff that's not in ?php? blocks as though each line were a print or echo statement. So your whole file will be compressed and sent to the browser. Regards, Sean On Sun, 4 Feb 2001, Alain Fontaine wrote: Rasmus, Thanks for the clarification; it seems obvious, too, that mixing compressed and non compressed content would be quite difficult to implement; at least it would partially compromise the speed/size gain because of added protocol overhead. Now, imagining that we have enabled compression by calling ob_start("ob_gzhandler"), what happens for a document that contains something along these lines: !-- snip -- ... ? // Enable HTTP compression ob_start("ob_gzhandler"); // PHP content $content = "This is some content."; ? divThis is a normal HTML section/div ? // PHP content continues $content .= "And the rest of it."; echo $content; ? ... !-- snip -- In this particular case, what would be compressed ? As far as I have understood, nothing at all, because some part of the output is not "passing through" PHP, right ? -Message d'origine- De : Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Envoye : dimanche 4 fevrier 2001 14:34 A : Alain Fontaine Cc : [EMAIL PROTECTED] Objet : Re: [PHP] HTTP compression I've just started experimenting with ob_start("ob_gzhandler") a bit, and I have found that if any output is generated before ob_start() is called, nothing at all gets compressed; if ob_start() is called before any output, everything is compressed. Is this the case, I mean, is this "by design" ? Yes, it wouldn't really work any other way. You can't mix non-compressed and compressed in the same request. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] HTTP compression
Alain Fontaine wrote: Sean, Thanks, I see. How about headers ? Do they need to be compressed, too; in other words, do headers "belong" to the output ? a HTTP response is made of response header(s) and the response body. Only the body is compressed, and this is signaled in the headers so the User Agent will know not to stare to a bunch of binary data :) -- teodor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] HTTP compression
Teodor, Looked at it from that point of view, the question was pretty stupid ! ;) -Message d'origine- De : Teodor Cimpoesu [mailto:[EMAIL PROTECTED]] Envoye : dimanche 4 fevrier 2001 19:09 A : Alain Fontaine Cc : Sean Cazzell; [EMAIL PROTECTED] Objet : Re: [PHP] HTTP compression Alain Fontaine wrote: Sean, Thanks, I see. How about headers ? Do they need to be compressed, too; in other words, do headers "belong" to the output ? a HTTP response is made of response header(s) and the response body. Only the body is compressed, and this is signaled in the headers so the User Agent will know not to stare to a bunch of binary data :) -- teodor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]