Re: gzip-based html compression
| From: | Zeev Suraski | Date: | Wed, 28 Jun 2000 19:34:50 +0000 |
| Subject: | Re: gzip-based html compression | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-3646@lists.php.net to get a copy of this message | ||
On Wed, 28 Jun 2000, Teodor Cimpoesu wrote:
> Hi Sebastian!
> On Wed, 28 Jun 2000, Sebastian Bergmann wrote:
>
> > "GZip-Encoding". Packing speed is about 200-500 Kb/sec on
> > Pentium-200. The unpacking takes virtually no time. It works on both
> > Apache and MS IIS."
> >
> > I understand that the "major" browsers (Netscape Navigator (Mozilla?),
> > MS Internet Explorer, ...) support the transport of gzip-compressed HTML
> > pages through HTTP.
> > Sadly I was not able to find information on this standard on w3.org.
> There was once a post on php3 mailing list about it, ans since then I am
> using it on my server. For static pages it's just a simple mod_rewrite trick.
> Check for accepted gzip encoding and rewrite the link to the .html.gz file.
>
> This is highly efficient for big html files (w/ lots of tables and formatting.)
>
> > I'd like to write, if possible, a small library in PHP that sends the
> > output of PHP scripts gzip-compressed, if the visitor's browser supports
> > this.
> Gzip compressing support exists for some time (just add --with-zlib when configuring),
> but for string compressing just from a recent date (iirc).
> So you may be able to use the trick for dynamic content too.
>
> You may enable output buffering from php.ini for all files and add
> an append file like:
>
> [gzip.php]
> $html = gzcompress(ob_get_contents());
> ob_end_clean();
> header ("Content-Type: text/html");
> header ("Content-Encoding: x-gzip");
> print ($html);
> ob_end_flush();
>
> *BUT*, unfortunately, PHP's content header is stubborned enough to
> get in our way every time. First time, you cannot get rid of it
> (I did filed a bug-rep) second, it insists to be the last one sent,
> so the "encoding" won't be seen :(
> e.g.
>
> HTTP/1.1 200 OK
> Date: Wed, 28 Jun 2000 19:06:19 GMT
> Server: Apache/1.3.12 (Unix) PHP/4.0.1
> X-Powered-By: PHP/4.0.1
> Content-Encoding: x-gzip
> Connection: close
> Content-Type: text/html
> <gzip-content-here>
>
> I'm just staring myself at mod_php4.c but I dunno what to change
> anyway :)
You mean you can't change the Content-Type?
I'll try to see if we can make the Content-Type header appear before the
rest of the header lines.
Zeev
--
Zeev Suraski <zeev@zend.com>
http://www.zend.com/