Re: stripping with an OB callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2006-09-20 at 20:21 -0400, Robert Cummings wrote:
> On Wed, 2006-09-20 at 17:13 -0700, Christopher Watson wrote:
> > I've been coding with PHP for maybe a year.  So I'm somewhat new to
> > it.  But I've learned quickly, and created a fairly serious LAMP app
> > that is capable of returning large query results.  During my
> > investigation into various means for incrementally reducing the
> > response sizes, I've discovered output buffering with a callback
> > function.  So, as an experiment, I bracketed my includes of the
> > Fusebox files in index.php with ob_start('sweeper') and
> > ob_end_flush(), and placed the simple callback function at the top of
> > the file that performs a preg_replace on the buffer to strip all
> > excess space:
> > 
> > function sweeper($buffer) {
> >     return preg_replace("/\s\s+/", " ", $buffer);
> > }
> > 
> > Results?  Kinda nice!  A large query result measuring over 900K of
> > HTML is reduced to 600K.  With no change at the browser.  Still valid
> > HTML, and the browser happily gobbles it up and displays it cleanly.
> > It's just 30% faster getting to me.
> > 
> > Now, the question.  Is this going to bite me in the ass?  'Cause right
> > now, it looks dang good to me.  Great bang for the buck, as far as I'm
> > concerned.  I've been churning it over in my head, and I don't see a
> > situation (certainly not in my particular app) where doing this
> > whitespace reduction is going to backfire.  There isn't anything in
> > any of this that requires the contiguous non-word characters.
> > 
> > I have a feeling though, that one of you more learned PHPers are going
> > to tell me exactly where my ass is gonna start hurtin'.
> 
> Should be an issue

That should have read "shouldn't" :)

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux