Jump to content
Sign in to follow this  
Snowman

[CONTRIBUTION] GZIP Compression 1.0

Recommended Posts

GZIP Compression will speed up the time it takes for your osCommerce pages to load on most servers.

 

The mod will now allow you to enable GZIP compression on your osCommerce website. GZIP compression can speed up the time it takes for a page to load.

 

This code will also remove wasted whitespace from the pages and also checks to see if you have GZIP enabled on your server. If GZIP isnt enabled it wont do any compression and the page will load nomally

 

To find out how much faster your pages could load try this tester

GZIP Tester

 

DOWNLOAD THE MOD HERE

Share this post


Link to post
Share on other sites

hmmm what browser are you using???

 

does this site load on your browser? http://www.snowtechsports.com

 

Not sure what the problem is...other than its possible that you have whitespace after the trailing ?> at the end of one of the files...

 

check the header, footer, default.php and application top.

 

If that doesnt work it may be an incompatability im not aware of.

Share this post


Link to post
Share on other sites

Oh burt i must also say...nice site...how have you got your hosting signup setup??? Im building a signup/billing system based on osC at the moment.

Share this post


Link to post
Share on other sites

hmmm trust it to not be fully compatable with every setup... :? :(

 

Just check php.ini to make sure you dont already have the following compiled:

 

output_handler = ob_gzhandler

 

If you do i think its a bit of double dipping and hence it wont work

Share this post


Link to post
Share on other sites

like this mod and Im going to install it.

 

However the gzip compression page you list - when I put your page in and run a test on the scnow sports one it comes back as not running gzip.

 

Is this a problem with the code or does the site have a problem.

 

Also I was wondering on older browser probs - will the page just not load if it cannot support gzip request in the browser or will it load an uncompressed one ?

 

Cheers,

 

Graham.


Graham Wright

________________

Share this post


Link to post
Share on other sites

Steve,

This mod is phenominal!

The difference that it makes to my pages is.. well... (from one Aussie to another in a Steve Kirwin 'Croc Hunter' voice... 'You Ripper!') :D :D

 

Only problem I've come across is that I'm using IIS 5 and my site is no longer showing locally.

 

I have looked at my phpinfo and it shows the following:

SERVER["HTTP_ACCEPT_ENCODING"] gzip, deflate

 

Do you know if there's any way in IIS 5 to encode with gzip locally? (Prefered Option) :wink:

If not, how do I switch it off so the pages are parse without the encoding?

 

Thanks,

Tony

 

P.S.

What are the downfalls of using gZip? (This seems too good to be true!)

Am I just sacrificing CPU time, or will I run into compatibility problems with client browsers?


"The price of success is perseverance. The price of failure comes much cheaper."

Share this post


Link to post
Share on other sites
What are the downfalls of using gZip? (This seems too good to be true!)

Am I just sacrificing CPU time, or will I run into compatibility problems with client browsers?

 

Remember that it is just the HTML being compressed, not the images. The images are already compressed in either GIF or JPG or whatever.

 

I have proposed a php/gzip feature internally and will spruce it up and contribute it soon.

 

There is some logic to enable gzip compression only if the client supports it.

 

Here are some rough benchmarks:

 

default.php:

Uncompressed length: 27774

Compressed length: 3753

 

product_info.php:

Uncompressed length: 25908

Compressed length: 4045

 

checkout_confirmation.php:

Uncompressed length: 25617

Compressed length: 3428


:heart:, osCommerce

Share this post


Link to post
Share on other sites
Remember that it is just the HTML being compressed, not the images. The images are already compressed in either GIF or JPG or whatever.

 

It does make a HUGE difference though...

To see the layout of the page instantly is great... the speed of the HTML loading will surely take their mind of the fact that the images are a little slower. Which aren't even that much slower... since the HTML isn't taking up precious 56k bandwidth.

(Sounds silly when talking 56k and bandwidth in the same sentence! :D)

 

I have proposed a php/gzip feature internally and will spruce it up and contribute it soon.

 

Can't wait!

 

There is some logic to enable gzip compression only if the client supports it.

 

What if the client doesn't support it? Will the pages just load as per normal without the compression?

(I'm guessing that 'client' is meaning that it gets decoded on the client browser... from what versions of each browser is gZip in-built?)

 

 

 

A little off the topic...

I've download the Win32 gZip contribution so I can gZip my backups locally. Though the 'define' statements in 'admin/includes/application_top.php' are causing problems when I upload the file to my server/host. It doesn't gZip any more. :(

Is there someway to incorporate an IF statement to see if you're on a local machine, then define them, but if you're on a www server to leave them alone?

 

Also, can I use the gZip in this contribution to gZip my pages locally? (I'm using IIS 5 and Win2K)

 

Thanks,

Tony


"The price of success is perseverance. The price of failure comes much cheaper."

Share this post


Link to post
Share on other sites
like this mod and Im going to install it.  

 

However the gzip compression page you list - when I put your page in and run a test on the scnow sports one it comes back as not running gzip.  

 

Is this a problem with the code or does the site have a problem.  

 

Also I was wondering on older browser probs - will the page just not load if it cannot support gzip request in the browser or will it load an uncompressed one ?  

 

Cheers,  

 

Graham.

 

Try http://www.snowtechsports.com now! i hadnt done that one yet :)

Share this post


Link to post
Share on other sites

What seems to happen is that rather than loading bit-by-bit there is a 10sec delay when nothing happens and then it all loads instantly (at least on broadband it does). Is that a feature of the compression?

Share this post


Link to post
Share on other sites

no thats a feature of a very buggy old shop, and the way i have the code setup on it at the moment.

 

The whole store will be going in for a rebuild when the milestone release comes out

Edited by Johnson

Share this post


Link to post
Share on other sites

actually, if you already have transparent zlib compression turned on in your php.ini, then this mod doesn't work


my@life# ./gf |touch|finger|mount|fsck|watch her

her@life$ ./men|more

Segmentation fault: Whore dumped

Share this post


Link to post
Share on other sites

actually what i really meant is that if your using the 2003/01/22 snapshot (which has this already included) with transparent zlib compression enabled, then adding this code to the store again broke things for me.

 

:roll:


my@life# ./gf |touch|finger|mount|fsck|watch her

her@life$ ./men|more

Segmentation fault: Whore dumped

Share this post


Link to post
Share on other sites
actually what i really meant is that if your using the 2003/01/22 snapshot (which has this already included) with transparent zlib compression enabled, then adding this code to the store again broke things for me.

 

Is the zlib compression enabled in php.ini or is it mod_gzip for Apache?

 

The GZip feature in CVS checks to see if zlib compression is enabled in php.ini and disables itself if the GZip feature is enabled.

 

There is currently no mod_gzip detection occuring.


:heart:, osCommerce

Share this post


Link to post
Share on other sites

its a PHP setting:

 

zlib.output_compression = On


my@life# ./gf |touch|finger|mount|fsck|watch her

her@life$ ./men|more

Segmentation fault: Whore dumped

Share this post


Link to post
Share on other sites
its a PHP setting:

 

zlib.output_compression = On

 

Right.

 

Here is the logic in application_top.php:

 

01: if ( (GZIP_COMPRESSION == 'true') && ($ext_zlib_loaded = extension_loaded('zlib')) && (PHP_VERSION >= '4') ) {

02:   if (($ini_zlib_output_compression = (int)ini_get('zlib.output_compression')) < 1) {

03:     if (PHP_VERSION >= '4.0.4') {

04:       ob_start('ob_gzhandler');

05:     } else {

06:       include(DIR_WS_FUNCTIONS . 'gzip_compression.php');

07:       ob_start();

08:       ob_implicit_flush();

09:     }

10:   } else {

11:     ini_set('zlib.output_compression_level', GZIP_LEVEL);

12:   }

13: }

 

Line 2 checks to see if zlib.output_compression is enabled or not - if it is, it sets the compression level with the GZIP_LEVEL parameter, and that is all - no further gzippin' is occuring :D


:heart:, osCommerce

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×