Use of gzip compression?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Use of gzip compression?

Post by seodevhead »

I have read a couple things on using gzip compression in php and was wondering if there were any disadvantages to using this would be? It seems like a great thing that could really speed up downloads and also lessen bandwidth, but is it too good to be true? Thanks for any advice and opinions.
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

We are using it on our servers and it cuts down the bandwidth usage by a HUGE margine. This helps both you and the person browsing your site. They don't have to wait as long for a page to load, especially if they are on a dialup connection.

Check this site out... http://web-sniffer.net/

You can use them to check out many different web sites to see if they have gzip enabled. If a site does it will list the compressed and uncompressed size of the html that was sent.

Check out our AATraders site. Click Here

Content (encoded: 18.79 KiB / decoded: 109.32 KiB)

You will see the gzipped page is 18k and if we turned off gzip the page would have been 109k. That's a HUGE difference in size and speed.

Check out a commercial site like CNN site. Click Here

Similar results... Content (encoded: 18.69 KiB / decoded: 98.47 KiB)

The only downside is that it will take a little extra processing power to compress the data but that is offset by the reduced processing power needed to send the smaller page.

I wish every site used gzip because it would make things so much faster.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Just to note several Windows firewall/anti-virus packages (cough...Norton...cough) may alter your browser's outgoing headers. The result is that if you force gzip (i.e. don't check the browsers acceptance of gzip content) pages may display as garbage (basically the ASCII representation of the gzip's content). Came across this on an afore mentioned website using Norton 2004 about a year or more ago (I don't use Norton anymore so not sure if fixed in any way).

Other than the small quibble, gzip is worth exploring and supporting.
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

Maugrim_The_Reaper wrote:Just to note several Windows firewall/anti-virus packages (cough...Norton...cough) may alter your browser's outgoing headers. The result is that if you force gzip (i.e. don't check the browsers acceptance of gzip content) pages may display as garbage (basically the ASCII representation of the gzip's content). Came across this on an afore mentioned website using Norton 2004 about a year or more ago (I don't use Norton anymore so not sure if fixed in any way).

Other than the small quibble, gzip is worth exploring and supporting.
Well Nortons's Firewall is about the worst firewall I have ever run across. I generally love Norton products and use them but their Firewall (Internet Security) package is a total pile of doggie poop. I would only recommend it to someone I hated and didn't want browsing the internet. None of the rest of Nortons software will touch your outgoing header information, not even Nortons Antivirus. It's just their IS Firewall that is total garbage.

Most DECENT firewalls will not alter your headers. :) Personally I use Zonealarm as it has never given me any trouble and not bad for a FREE firewall.

And Maugrim is right you should always check to see if the browser supports gzip befor using it. Such as...

Code: Select all

if(strstr($_SERVER["HTTP_ACCEPT_ENCODING"],"gzip"))
{
// ok, gzip encode everything
}
Some people may tell you not to use gzip because of problems with IE. There is a BUG in IE they have never fixed. If you try to view a gziped web site through a proxy you will see garbage because IE cannot decode gzipped data when sent through many proxies. As long as you do not use IE through a proxy it will view gzipped pages just fine.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

AKA Panama Jack wrote:Some people may tell you not to use gzip because of problems with IE. There is a BUG in IE they have never fixed. If you try to view a gziped web site through a proxy you will see garbage because IE cannot decode gzipped data when sent through many proxies. As long as you do not use IE through a proxy it will view gzipped pages just fine.
Is there a way to test against this situation?
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

X-Forwarded-By?
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

Not that I know of. That's why some sites have gzip turned off. Personally, IE users can go suck lemons if they are behind a proxy for all I care. :D They should be using a better browser. :D
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

AKA Panama Jack wrote:Not that I know of. That's why some sites have gzip turned off. Personally, IE users can go suck lemons if they are behind a proxy for all I care. :D They should be using a better browser. :D
Well unfortunately, due to Microsoft bundling IE with Windows, most people don't know there's an option.

EDIT: But now that I think about it, generally if something is behind a proxy, it has a network administrator or two and if so, that means they will likely be aware of this problem. I believe the benefits of gzip outweight the small margin of people in IE behind proxy
Post Reply