RE: [PHP] Need a tool to minimize HTML before storing in memecache

[email protected] ("Daevid Vincent")
Newsgroups php.general
Message-ID <[email protected]>

> -----Original Message-----
> From: Matijn Woudt [mailto:[email protected]]
> Sent: Wednesday, April 17, 2013 3:11 PM
> To: Daevid Vincent
> Cc: PHP List
> Subject: Re: [PHP] Need a tool to minimize HTML before storing in
> memecache
> 
> On Wed, Apr 17, 2013 at 11:52 PM, Daevid Vincent <[email protected]>
> wrote:
> 
> > We do a lot with caching and storing in memecached as well as local
> > copies so as to not hit the cache pool over the network and we have
> > found some great tools to minimize our javascript and our css, and now
> > we'd like to compress our HTML in these cache slabs.
> >
> >
> >
> > Anyone know of a good tool or even regex magic that I can call from
> > PHP to compress/minimize the giant string web page before I store it in the
> cache?
> >
> >
> >
> > It's not quite as simple as stripping white space b/c obviously there
> > are spaces between attributes in tags that need to be preserved, but
> > also in the words/text on the page. I could strip out newlines I
> > suppose, but then do I run into any issues in other ways? In any
> > event, it seems like someone would have solved this by now before I go
> > re-inventing the wheel.
> >
> >
> >
> > d.
> >
> >
> How about you just compress it? Gzip, bzip2, etc. Pick your favourite.
> http://www.php.net/manual/en/refs.compression.php
> 
> - Matijn

Well we already use the gzip compression that is built into Apache since that works in tandem with the client too. 
http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/

The point of minification is to remove comments, commented sections, optimize the code by removing closing tags when not needed (</p> or <br/>), strip unnecessary white space, etc.. there is more to it than just squeezing bits which is what LZO or GZIP do. They work in conjunction with each other.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.