Forum Moderators: phranque

Message Too Old, No Replies

Question about Apache modules

         

nrobidoux

10:00 am on Nov 26, 2008 (gmt 0)

10+ Year Member



I'm working on a project where this company NEEDS to reduce their bandwidth client-side. Their site targets many people in developing nations where they are still on dialup.

There were some changes that I made which were useful but I'm trying to squeeze out as much as possible. One thing computers don't need to see is whitespace although it certainly makes files more readable for us.

I had wrapped everything in PHP that way the WS would be eliminated but it takes forever... and there's still some left in CSS files... and the other PHP files I haven't modified yet.

Is it possible to somehow pipe the output of PHP module for Apache (and all GET requests for files of text/* mime-types) to a PHP script that removes the WS and then sends the result to fulfill the client's HTTP GET request?

I had a near 10% reduction by eliminating WS so it isn't as trivial as it may seem :) I figure the script is simple....

echo ereg_replace("\n(\t+¦ +)?","",however i read the input from the php module/apache);

The hard part for me incorporating it with Apache.

Thanks

nrobidoux

12:02 pm on Nov 26, 2008 (gmt 0)

10+ Year Member



Hmm I wrote a PHP script awhile back to "look at" craigslist. I just simple copied most of the headers of the GET request..... and remembering getting back gibberish.

Which was craigslist G-zipped.... (might've been Google can't remember)

This thread might've become a lot simpler. I assume IE6/7 and FF1+ all accept gzip. This could be the way to go and would be way smaller..... (I hope the images don't grow too much)

How is this enabled?..... (As I surf the web I find my answers)

But still if I can shrink the file even more by removing the WS that'd be very useful

jdMorgan

2:51 am on Dec 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you go the compression route, then the WS issue becomes less important.

However, you might want to look into saving your source files without extra whitespace, and using an editor that will "pretty-print" them only while you are working on them.

Also, look at the cache-control and expires headers sent by your server for various filetypes. Set up properly, you can tell the client browser to cache images for weeks or months, CSS and JS for at least 24 hours, and normal 'pages' for at least an hour or so. Error pages should be marked uncacheable, and anything that expires in less than an hour should probably be marked with a 'must-revalidate' Cache-control header.

You may see a marked reduction in server bandwidth (implying less client bandwidth) by implementing appropriate and correct cache-control and expires headers.

The 'Live HTTP Headers' add-on for Firefox/Mozilla browsers is very useful for examining client and server HTTP headers, including those used for cache and expiry control.

Jim

nrobidoux

8:01 am on Dec 2, 2008 (gmt 0)

10+ Year Member



Thanks Jim. I already Live HTTP Headers... I love it :D

Cache control is something I don't have much experience with but I'm looking into it. My only other improvement I offered is to try and cut down on the heavy image use. I already converted GIFs to heavily compressed JPEGs... and before this post and installing GZIP I edited all the CSS and PHP files that are part of the template they have.