Speed up your pages the quick, easy, and painless way (Full Version)

All Forums >> [Community] >> OutFront Discoveries



Message


womble -> Speed up your pages the quick, easy, and painless way (10/15/2006 7:40:25)

I'm working on a site at the moment, and on one particular page I have an include that's form that you input a value into, and the form trundles off around the intraweb and returns interesting information on. Works nicely...but...the form returns the result to itself, resulting in the page reloading, and while it's busy handling all the data, it makes the page reload quite slowly. The main problem with this is that for some unknown reason I've not managed to fathom yet, the page background loads last (it's not a background image, just a "background-color" in the CSS). I've still not managed to figure out why - it's got to be something to do with either the cascade or how I've got the page laid out in <divs>, but I've not had time to get to the bottom of it yet and I've had this problem crop up on odd pages before from time to time. It's an irritation though, so this morning I set off a-googling to see if I could find out what might be causing it - still not managed to get to the bottom of it, but what I have found is something that's solved the problem, in a way that's altogether too easy.

While wandering around I kept seeing reference to "mod_gzip"...

quote:

mod_gzip is an Apache web server module that compresses the HTML as it sends it out. It is compatible with all browsers (old browsers that don't support gzip content will get uncompressed HTML). Using gzip can save you HUGE amounts of bandwidth, and increase the overall performance of your webserver. It also makes a world of difference for people viewing your site on a dial-up modem.


...but after reading round a bit, discovered that it can be difficult to set up and not all hosts support mod_gzip, but then I came across this (down towards the bottom of the page) - you simply add this to the top of your page:
<?php
ob_start("ob_gzhandler");
?>


...and it automatically gzips the page for browsers that support it. It works with all browsers (though v old browsers that don't support gzip just get it uncompressed), and as most webservers support PHP, it can be used on most pages, and all you have to do is change your files from mypage.html to mypage.php - if you're already using php anyway, it's just an extra line in the top of the page. There's also a discussion here on this method, and another method to compress your pages using .htaccess.

Here you can find a handy tool for testing for gzipped content (or any other compressed content), or test an uncompressed page to see how much bandwidth you could save by compressing your pages. I tried it out on the page I've been having problems with, using the 'stick the php code in the top of the page method' and got this result:
quote:

Original Size: 15 K
Gzipped Size: 5 K
Data Savings: 66.67%


It made all the difference to the page I've been having problems with. [img]http://ganjataz.com/Forum/images/smiles/happyspin.gif[/img]

- speed up your page load times
- use less bandwidth
- make your pages friendlier for 56k dial-up visitors




Spooky -> RE: Speed up your pages the quick, easy, and painless way (10/15/2006 13:03:23)

A great way to test the results is :
http://www.websiteoptimization.com/services/analyze/index.html

And some more info on compression :
http://www.seoconsultants.com/tools/compression.asp




jaybee -> RE: Speed up your pages the quick, easy, and painless way (10/15/2006 13:10:06)

Eureka! Thanks Wombly. Don't know why I did't think of Gzip before.

Page Size: 10 K
Size if Gzipped: 3 K
Potential Savings: 70%




BobbyDouglas -> RE: Speed up your pages the quick, easy, and painless way (10/15/2006 13:40:35)

gzip is especially great for clean designs.

I wrote a nice tutorial on this awhile ago called PHP Compression

The GIDZipTest got me started on PHP Compression awhile ago (the coder of the script has spent quite a bit of time tweaking the settings and such).

The .htaccess code (which can also server in the apache conf file too) is:
quote:

php_flag output_buffering On
php_value output_handler ob_gzhandler
php_flag zlib.output_compression Off


In order to use gzip, you need the zlib module. In order to tell if you have that, create a new php page with the following info inside:
<?php
phpinfo();
?>


Then search for the zlib module




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
6.201172E-02