|
Posted by Rory Browne on 10/17/13 11:15
First of all as Rasmus said, this 'compression' is barely(if at all)
going to make a difference, after your pages have been compressed wth
gzip,
There are two reasons for this:
1 compression techniques detect repeated strings(such as spaces or
newlines), and replaces them with one instance of that string, and a
record of how many times it appears.
2 Because Rasmus said so, and considering his long-time involvement
with the php project(as founder), he probably knows what he'e talking
about.
What might be more useful is stripping out comments, If you don't use
javascript it is simply a case of replacing all <!-- anything --> with
a blank space. If you do though it's more complicated since it is
considered good practice to place js inside <!-- .. //--> blocks, and
you have the additional talk of replacing out // and /* .. */
comments.
but if you really want to do it then:
function ob_whitespace_removal($str){
// would need to dbl_check regex/modifiers
return ob_gzhandler(preg_replace("/\s+/m", " ", $str));
}
should work, Although for purists/modularity output buffer stacking
may be a cleaner technique
Re: Internet Explorer Problems:
if you check the ob_start or ob_gzhandler pages on the php
manual(online version) then you'll find a user-submitted comment
saying that MSIE doesn't cache compressed stuff. This doesn't matter
for a dynamic website. Try googling, but don't say ob_gzhandler, since
this is (allegedly) a problem with IE/gzip compatability, and not the
ob_gzhandler implemention(ie search for gzip and not ob_gzhandler).
On 5/7/05, Kirsten <neretlis@westnet.com.au> wrote:
> >preg_replace('/s+/', ' ', $html);
> >
> > but watch out, this js code will work:
> >
> > var v
> > alert(v)
> >
> > this one will not:
> >
> > var v alert(v)
>
> Sure....
> but now: how do I access the htm output of the current executing script
> before it is send to the user?
>
> Thanks again
>
> >
> > >
> > > 1) Is there any function to do this (I'm using PHP 4.2) ? Or maybe some
> user
> > > has already done it?
> > > 2) Is it true that ob_start("ob_gzhandler") can cause problems on IE
> 5.5+?
> >
> > don't know. but you can detect these browsers and turn compression off
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Navigation:
[Reply to this message]
|