Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Compressing Pages


spooks

Recommended Posts

yours only took about 4 seconds on my cpu here.

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Link to comment
Share on other sites

  • 4 weeks later...
  • Replies 80
  • Created
  • Last Reply

There has been some talk that using gzip increases the server load which may cause problems if your site has lots of traffic.

However I notice that with gzip enabled page parse time are significantly reduced.

 

Does anyone have any experiance of any problems using gzip?

Has anyone used gzip, then reverted for some reason.

 

My research shows that most top sites running on apache servers use gzip, they cant all be wrong.

Some may argue that they can afford the bandwidth so dont need to enable, but that ignores the user with a slow connection that would benifit greatly by the reduced size.

 

 

 

I`ve found a good test site if you wish to check yours: http://www.gidnetwork.com/tools/gzip-test.php

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

There has been some talk that using gzip increases the server load which may cause problems if your site has lots of traffic.

However I notice that with gzip enabled page parse time are significantly reduced.

 

Does anyone have any experiance of any problems using gzip?

Has anyone used gzip, then reverted for some reason.

 

My research shows that most top sites running on apache servers use gzip, they cant all be wrong.

Some may argue that they can afford the bandwidth so dont need to enable, but that ignores the user with a slow connection that would benifit greatly by the reduced size.

 

 

 

I`ve found a good test site if you wish to check yours: http://www.gidnetwork.com/tools/gzip-test.php

Web page compressed? Yes

Compression type? gzip

Size, Markup (bytes) 61,944

Size, Compressed (bytes) 7,985

Compression % 87.1

 

Does not mean anything much, except that it confirms the page as being compressed.

Link to comment
Share on other sites

Great mod as others have said. but when I was going to do the same to a phpBB forum I run, There's a warning message about enabling Gzip:

 

"Generated content will be compressed prior to sending it to the user. This can reduce network traffic but will also increase CPU usage on both server and client side."

 

I take that to mean, that anyone with an old machine their page load times increase?

 

So I'm not so sure about enabling the mod now?

Link to comment
Share on other sites

A 'client' would have to have a very old slow machine to be effected by this, such would be so rare as to of no consequence. A slow connection is far more common & that would benifit.

 

Any increased load on the server appears to only be an issue where high traffic is an issue, so make your judgment based on that & your servers cpu capability.

 

As I've said most top sites running on apache servers use gzip, the few using windows (microsoft & some yahoo to my knowledge!) don't as its not an option.

 

I note this forum uses compression.

 

:)

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

I have all of my sites compressed, however, I just downloaded safari for a quick test and these sites will not load in safari. Once gzip compression is disabled they load perfectly fine without compression. Any ideas as to why that would happen?

Link to comment
Share on other sites

Very odd, I turned it on and have had great results in both FireFox & Safari. I am running an iMac. Check out my site at www.13thgreen.com and see if it loads fine for you.

Link to comment
Share on other sites

I've come to suspect its something in my server not sending the correct http headers. I just cant seem to get it figured out. I've googled for 2 days with no success.

 

 

Have you submitted your site, to that test page, see if that shows anything odd.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

After some help from others, this is what I've been told. My server is using Apache 2.0. In apache 2, mod_gzip has been replaced by mod_deflate. I've also been told I need to code the site to use mod_deflate rather than gzip. So I was given these two links to try to figure out how to code this myself.

 

http://www.cpanel.net/support/docs/easyapa...late_module.htm

 

http://httpd.apache.org/docs/2.2/mod/mod_deflate.html

 

I'm afraid I dont actually have the skill level to accomplish coding this one on my own. So, I guess gzip is off for the moment.

Link to comment
Share on other sites

After some help from others, this is what I've been told. My server is using Apache 2.0. In apache 2, mod_gzip has been replaced by mod_deflate. I've also been told I need to code the site to use mod_deflate rather than gzip. So I was given these two links to try to figure out how to code this myself.

 

http://www.cpanel.net/support/docs/easyapa...late_module.htm

 

http://httpd.apache.org/docs/2.2/mod/mod_deflate.html

 

I'm afraid I dont actually have the skill level to accomplish coding this one on my own. So, I guess gzip is off for the moment.

 

 

I think your host is just being lazy, not wanting to set it up, yes apache 2 uses mod_deflate but the compression is still gzip, I have sites on apache 2.2 with no problems using it.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

So, if the mod_deflate is set up correctly on the server, turning on gzip in oscommerce will work?

 

 

yes, should work fine then.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

after installing fck editor and lot of contrib in my admin i find it s a little bit long to load

i installed the code in my admin application_top , but i go not any clue how effcient is the gzip compression, any experiences ?

MS2

Link to comment
Share on other sites

You should see a big increase in speed, there is a test page here

 

If you used the code from clients side as detailed in that other thread I'm not sure if it will work, I have'nt checked but it may never get activated, use the code I gave above instead.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Well, it IS my code that is causing the issues with Safari.

 

In my gzip_compression.php I added this at one time:

 

 # Return the compressed buffer
function compress_buffer ($buffer) {
  # strip blank lines (blank, with tab or whitespaces)
  $buffer = preg_replace("/[\r\n]+[\s\t]*[\r\n]+/","\n",$buffer);
  # join lines
  $buffer = str_replace("[\r\n]", ' ', $buffer);
  # strip whitespace between > and <
  return preg_replace('/\>[\s\t]+\</', '> <', $buffer);
}

 

Which I absolutely love to have, it really cleans up the code. However, safari does NOT like it.

 

I added this after reading this topic http://www.oscommerce.com/forums/index.php?showtopic=144736 some time ago, but just recently I've had the issues with safari. It may be because of the servers apache, php and mysql updates last month that is messing something up with safari.

Link to comment
Share on other sites

Well, here's my resolution.

 

The mod_deflate on my server compresses the pages just fine (when optimize site is turned on in cpanel). I dont need to turn on gzip in my osc admin (in testing, on or off I have the same level of compression). I have reverted back to the original ms2.2 gzip_compression file and turned gzip off.

 

Now, I really like having the code cleaned up. So, I added this to my application_top.php at the top, just after Released under the GNU General Public License */

 

/* initialize compress function for whitespace removal */
ob_start("compress");
/* Begin function compress */
function compress($buffer) {
  # strip blank lines (blank, with tab or whitespaces)
  $buffer = preg_replace("/[\r\n]+[\s\t]*[\r\n]+/","\n",$buffer);
  # join lines
  $buffer = str_replace("[\r\n]", ' ', $buffer);
  # strip whitespace between > and <
  return preg_replace('/\>[\s\t]+\</', '> <', $buffer);
/* remove unnecessary spaces */		
$buffer = str_replace('{ ', '{', $buffer);
$buffer = str_replace(' }', '}', $buffer);
$buffer = str_replace('; ', ';', $buffer);
$buffer = str_replace(', ', ',', $buffer);
$buffer = str_replace(' {', '{', $buffer);
$buffer = str_replace('} ', '}', $buffer);
$buffer = str_replace(': ', ':', $buffer);
$buffer = str_replace(' ,', ',', $buffer);
$buffer = str_replace(';', ';', $buffer);

return $buffer;
}

 

I can now see my site in safari. The code is generally clean (I'm sure it could be cleaned up even more). The pages load much faster.

 

Do you see any reason this would not be a good idea?

Link to comment
Share on other sites

Nice topic, thanks!

 

I had configured my store so long ago, that I hadn't bothered changing any settings in ages. And now I just found out that I had gzip compression disabled on my admin... I turned it on at compression 5, and my index html went down from 50871 uncompressed to 7492 compressed. My full index with images, stylesheets, and everything has gone down from 147900 bytes to 95087bytes.

 

Not that I think that will make me have more customers, but it can't be bad! :D

MindTwist of Twisted Reality and Twisted Tienda

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

Many thanks to spooks for bringing this to my attention!

I already had the gzip function enabled at 9 in admin but this makes a huge difference.

I decided to have a look at the code.

I made a couple more minor changes in includes/application_top.php

At line 78, I changed the PHP_VERSION from 4 to 5, as I know my server uses PHP5.

And on line 79, I changed the 8 at the end of the line a 9.

Now my site is absolutely flying - 80% compression!

I'm not sure if it will cause any problems, I hope not.

Seems to work well with IE7 and Firefox 3.0.3

 

// if gzip_compression is enabled, start to buffer the output
 if ( (GZIP_COMPRESSION == 'true') && ($ext_zlib_loaded = extension_loaded('zlib')) && (PHP_VERSION >= '5') ) {
if (($ini_zlib_output_compression = (int)ini_get('zlib.output_compression')) < 9) {
  if (PHP_VERSION >= '4.0.4') {
	ob_start('ob_gzhandler');
  } else {
	include(DIR_WS_FUNCTIONS . 'gzip_compression.php');
	ob_start();
	ob_implicit_flush();
  }
} else {
  ini_set('zlib.output_compression_level', GZIP_LEVEL);
}
 }

----------------------------------------------------------------------------------------------

Results from: GIDZipTest

Web page compressed? Yes

Compression type? gzip

Size, Markup (bytes) 46,407

Size, Compressed (bytes) 8,872

Compression % 80.9

--------------------------------------------------------------------------------------------------

Link to comment
Share on other sites

Meant to add Google Chrome seems okay too.

And, a very useful site for this kind of thing: Browser Shots

On the Browser Shots site, you can enter your own website name and after a short wait, you'll be able to see how your site appears in multiple browsers, versions, and operating systems (Windows/Linux/Apple/etc)

--------------------------------------------------------------------------------------------------

Link to comment
Share on other sites

Web page

compressed? Yes

Compression type? gzip

Size, Markup (bytes) 348,942

Size, Compressed (bytes) 56,987

Compression % 83.7

 

Yeah that helped!!!

Previous parse times were between 1.0 - .7

now parse times are from .48 to .29

(always on product_info for our site)

 

Another thing I noticed was under Cache-control:

 

I have...

no-store, no-cache,

must-revalidate,

post-check=0,

pre-check=0

 

It's a big database of products, I was advised somewhere to forgo page cache and such. Any thoughts, anyone?

Link to comment
Share on other sites

Hi

 

When I enable GZip and go here to test it.

 

http://www.gidnetwork.com/tools/gzip-test.php

 

It tells me that

 

Web page compressed? Yes

Compression type? gzip

Size, Markup (bytes) 53,792

Size, Compressed (bytes) 7,553

Compression % 86.0

 

 

However below this it also tells me that the Response Headers have changed from a status of HTTP/1.1 200 OK to HTTP/1.1 500 Internal Server Error

 

Is this anything to worry about?

 

Regards

 

Ken.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...