Jump to content



Latest News: (loading..)

* * * * * 1 votes

Compressing Pages


This topic has been archived. This means that you cannot reply to this topic.
80 replies to this topic

#1   spooks

spooks
  • Members
  • 7,017 posts

Posted 27 May 2008 - 11:14 PM

This may be placed elswhere but I could'nt find it in this version.

This dead simple mod compresses pages at the server as they delivered to the client browser (if it supports compression) using gzip.

It can give upto 80% reduction in size, so speed download, there is no extra load to server.

There is a option in admin, so if you have that 'on' don`t apply this to the client side.

This can be done for any php document.

In application_top.php both on client side & admin, near the top, after <?php

add:

ob_start("ob_gzhandler");

Thats it, you should notice a speed increase on loading admin pages immediatly, client pages will be faster, especially if using dial-up.

I have`nt found any downside to date.
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.

#2   NimaP

NimaP
  • Members
  • 144 posts

Posted 28 May 2008 - 10:38 PM

which browsers don't support gzip?

#3   spooks

spooks
  • Members
  • 7,017 posts

Posted 28 May 2008 - 10:54 PM

View PostNimaP, on May 28 2008, 11:38 PM, said:

which browsers don't support gzip?

IE 3 & older, Opera 4 & older Netscape 3 & older, and certain versions of firefox (not sure which)
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.

#4   Java Roasters

Java Roasters
  • Members
  • 2,145 posts

Posted 29 May 2008 - 04:50 PM

I already have this in my version of MS2.2

// if gzip_compression is enabled, start to buffer the output
if ((GZIP_COMPRESSION == 'true') && ($ext_zlib_loaded = extension_loaded('zlib')) &&
	(PHP_VERSION >= '4')) {
	if (($ini_zlib_output_compression = (int)ini_get('zlib.output_compression')) < 1) {
		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);
	}
}


#5   spooks

spooks
  • Members
  • 7,017 posts

Posted 30 May 2008 - 10:44 AM

View PostJava Roasters, on May 29 2008, 05:50 PM, said:

I already have this in my version of MS2.2

// if gzip_compression is enabled, start to buffer the output
if ((GZIP_COMPRESSION == 'true') && ($ext_zlib_loaded = extension_loaded('zlib')) &&
	(PHP_VERSION >= '4')) {
	if (($ini_zlib_output_compression = (int)ini_get('zlib.output_compression')) < 1) {
		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);
	}
}


Hi, I did mention the option in admin, which controls this bit of code, the point of this tip is to make people aware of this very handy option & how to apply it in admin as well, or any other php pages.

Try it on your admin & see just how much quicker they load.

;)
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.

#6   NimaP

NimaP
  • Members
  • 144 posts

Posted 04 June 2008 - 04:08 PM

wow..i just applied this to my admin.

what a difference in speed! great tip!

#7   Coopco

Coopco
  • Members
  • 9,557 posts

Posted 05 June 2008 - 08:12 AM

Hey Spooks, thanks. Have seen that option for yonks but never touched it till now. I think load times have halved and I am using the default value of 5..


The Coopco Underwear Shop



If you live to be 100 years of age, that means you have lived for 36,525 days. Don't waste another, there aren't many left.

#8   WoodsWalker

WoodsWalker
  • Members
  • 389 posts

Posted 06 June 2008 - 02:56 AM

This is way cool, Sam. Thanks!   B)

~Wendy

#9   joebloggs

joebloggs
  • Members
  • 35 posts

Posted 07 June 2008 - 03:42 PM

Fantastic tip m8 i never knew what that was for !!!!!!!!!!!!   :lol: :lol: :lol: :lol:

#10   dreakies

dreakies
  • Members
  • 3 posts

Posted 10 June 2008 - 01:11 AM

Thanx! Great tip!

#11   cmakynen

cmakynen
  • Members
  • 54 posts

Posted 10 June 2008 - 01:51 AM

Wow - that works great - thanks!
Just curious - if an old non-supporting browser opens a page with this code in it. what happens?  It croaks, or it just passes over it?

#12   dark_tyrant

dark_tyrant
  • Members
  • 53 posts

Posted 10 June 2008 - 07:02 AM

What does the unsupported browsers show when using this?

#13   spooks

spooks
  • Members
  • 7,017 posts

Posted 10 June 2008 - 06:59 PM

View Postdark_tyrant, on Jun 10 2008, 08:02 AM, said:

What does the unsupported browsers show when using this?

Thay wont show any differance, the server will detect the browser does'nt support compression, so will serve uncompressed pages, so the only differance will be the load speed.
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.

#14   WoodsWalker

WoodsWalker
  • Members
  • 389 posts

Posted 11 June 2008 - 03:02 PM

Even MORE cool!   B) B)

#15   dark_tyrant

dark_tyrant
  • Members
  • 53 posts

Posted 12 June 2008 - 01:24 AM

View Postspooks, on Jun 10 2008, 02:59 PM, said:

Thay wont show any differance, the server will detect the browser does'nt support compression, so will serve uncompressed pages, so the only differance will be the load speed.

Interesting. Thanks for the information.

#16   quick

quick
  • Members
  • 47 posts

Posted 17 June 2008 - 08:17 AM

I am sorry, I donot get clear myself. Hope somebody can help me out.

in admin >Configuration >GZip Compression, if i set to "ture" and the level to "3",

can i still add "ob_start("ob_gzhandler");" in catalog/ admin/includes/application_top.php and catalog/incule/application_top.php

i just confuse i have got speed up in admin after add ob_start("ob_gzhandler");" in catalog/ admin/includes/application_top.php.

Anything i have done wrong?

#17   spooks

spooks
  • Members
  • 7,017 posts

Posted 17 June 2008 - 05:27 PM

View Postquick, on Jun 17 2008, 09:17 AM, said:

I am sorry, I donot get clear myself. Hope somebody can help me out.

in admin >Configuration >GZip Compression, if i set to "ture" and the level to "3",

can i still add "ob_start("ob_gzhandler");" in catalog/ admin/includes/application_top.php and catalog/incule/application_top.php

i just confuse i have got speed up in admin after add ob_start("ob_gzhandler");" in catalog/ admin/includes/application_top.php.

Anything i have done wrong?

If you set to true as above then yes still add to catalog/ admin/includes/application_top.php as that setting has no effect on the admin side, but do not add to catalog/includes/application_top.php  as that would generate an error & is not then required anyway.

I hope that makes it clearer.

:)
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.

#18   quick

quick
  • Members
  • 47 posts

Posted 19 June 2008 - 03:22 AM

View Postspooks, on Jun 17 2008, 06:27 PM, said:

If you set to true as above then yes still add to catalog/ admin/includes/application_top.php as that setting has no effect on the admin side, but do not add to catalog/includes/application_top.php  as that would generate an error & is not then required anyway.

I hope that makes it clearer.

:)

Thanks Sam very much, your answer make me clear, i did find error when i add to catalog/includes/application_top.php. I really hope i can speed up the client side.  :rolleyes:

#19   Bruin_03

Bruin_03
  • Members
  • 219 posts

Posted 03 July 2008 - 12:55 PM

Nice share. Thanks!

#20   tuliptechnologies

tuliptechnologies
  • Members
  • 14 posts

Posted 07 July 2008 - 01:50 AM

Hello.

Can anyone assist me why my website (www.firstalberta.com) is taking too long time to load the first page/time ?

I applied all suggestions as stated above like turn on GZIP and reduce the image size too.

Please let me know how to tune, it is taking nearly 30 to 40 sec's and i need to load the page in 1 sec.

--
Thanks in Advance,
Kart.