PDA

View Full Version : Make your directory Fly: How to GZIP Compress


gustotelmy
01-21-2006, 07:05 AM
I am not a programmer however I do have some tricks I can show to people that may not know how to speed up your directory. The answer is to use GZIP or compression technology like the big guys yahoo, msn, and google.

how?
You can easily shave off almost half of your bandwidth and download time for your directory using GZIPPING....

most hosts use it if they use PHP....

how to apply this "mod" :D (its the easiest of em all!):

open index.php
before ANY code add this:

<?php
ob_start( 'ob_gzhandler' );
?>

You are done!! To get a feel for how much speed you gained and bandwidth check:
http://www.websiteoptimization.com/services/analyze/

Compare before and after....

I gzipped my css file to 1/3 its original size using two things:
1)
http://www.cssdrive.com/index.php/main/csscompressor/

and
2)
then changing the css file type from .css to .php and adding
<?php
ob_start ("ob_gzhandler");
header("Content-type: text/css; charset: UTF-8");
header("Cache-Control: must-revalidate");
$offset = 60 * 60 ;
$ExpStr = "Expires: " .
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);
?>

to the top of the php file

Make sure you refer to the php (css) file in the following way:
<style type="text/css">
@import url("http://www.yoursite.com/pathto/cssfilename.php");
</style>

im done :D my first contribution...if you call it that :P

KNOWN PROBLEMS: may influence MSN rankings? (not sure 100%) - please post here if you know anything about Gzipping and MSN SERPS

gamecock
01-21-2006, 12:25 PM
Wow, what huge site speed increase! Thanks!

Moncal
01-21-2006, 01:46 PM
You're my hero!

I'm on dialup and my directory just literally loaded in 2 seconds!

dagger
01-21-2006, 05:53 PM
nice work dude :)

its better by 60%

gustotelmy
01-21-2006, 11:12 PM
:D you are welcome ! I am trying to give back to this great community...

it works in other php documents too such as your main pages also...

all the best

David
01-22-2006, 12:38 AM
Interesting...I will have to test this for 3.0.
I'm starting to get the dev area setup, and soon we'll start combing the forums for miscellaneous bug fixes and improvements.

Ap0s7le
01-22-2006, 01:31 AM
David, I was thinking the same thing.

:)

later

resource
01-22-2006, 04:46 PM
You can do it from php.ini for every PHP script easily, just edit your php.ini and find zlib.output_compression and set it to On like:
zlib.output_compression = On
Don't touch anything else, and restart your Apache.

Cheers

gustotelmy
01-23-2006, 07:35 PM
glad everyone likes it!

the cool thing is it works for people that have browsers enabled for compression ie 99% of them, the rest the server just serves up the un-compressed copy so need to worry about losing visitors...

:D

gearoid
04-18-2006, 10:47 PM
Excellent,
Thank you.

Brandon Sheley
04-19-2006, 07:23 AM
works for me, thank you :)

vignesh_natraj
06-22-2006, 05:43 PM
great post i didn't use it for phpLD but another php script
the result was great thank you

kentuckyslone
06-23-2006, 03:46 AM
Very good! According to http://www.websiteoptimization.com/services/analyze/ my home page went from 19 seconds to 12 seconds for the slowest (14.4) connection speed after making this change.

gustotelmy
07-06-2006, 02:38 AM
:) love to see people using it!

Boby
07-06-2006, 02:55 AM
It can be done also from your .htaccess file:
Content visible to registered users only.

But make sure your hoster and webserver allows it, else you'll get a 500/Internal Server Error if it's disabled.

Boby

Brandon Sheley
07-06-2006, 03:28 AM
when this was enabled on 3.0.5 i had description errors from search results :(

Brandon Sheley
07-06-2006, 06:38 AM
ya, i get a lot of traffic from msn, so I had to disable this :(

CyberGrenade
07-06-2006, 07:49 PM
I noticed a HUGE difference in my Directory. Thanks for the post.

gustotelmy
07-10-2006, 07:34 AM
Content visible to registered users only.


hmm are u serious? **censored****censored****censored****censored**. Msn better wake up this is important to speed up the net. I never thought of SEO implications although I consider myself a pretty good SEOer... sorry for this :(

gustotelmy
07-10-2006, 07:36 AM
Content visible to registered users only.


cool! that is easier

mystickcal
08-02-2006, 10:18 PM
I see that it was said that you can do this all from your php.ini file. I looked on my hosting and didn't see a php.ini file. I called my hosting and they said you can do it, you just have to make your own using like notepad. My question is what all goes in this ini file? They told me to goto php.net to find out, but I couldn't find anything about .ini files that I understood lol.

anon
08-02-2006, 10:19 PM
Content visible to registered users only.
The post right above your tells you exactly what to put in yout .htaccess file.

mystickcal
08-02-2006, 10:32 PM
Right, I saw the .htaccess file one, but I can't do it that way. My hosting company doesn't allow me to. I know before you say switch hosting companies they are paid for like a year so I really don't want to do that.

Boby
08-03-2006, 06:56 AM
@ mystickcal

Just create a file called php.ini in your public_html but it would maybe also work in the root folder of your directory.
Add following code to it:
Content visible to registered users only.

I had no time to test it, but I hope it works, I got this from the php.ini reference.
More help maybe here:
http://www.php.net/manual/en/ini.php#ini.list

gustotelmy
08-03-2006, 07:03 AM
Content visible to registered users only.

hey anon, do you still think its gzip compression that made you lose MSN rankings?

I think its **censored****censored****censored** if its true as I believe MSN even uses gzip compression... their spiders really suck if true!

anon
08-03-2006, 08:43 AM
Content visible to registered users only.
I am uncertain at this point. My rankings have climbed back up again and I am listed top 5 for some great key terms. Still the problem of the garbled description remains. How in the hell do I get it out is beyond me. Their sipder visits my site enough to be able to correct it, but they seem to be taking their sweet time abotu it. *sigh*

Boby
08-03-2006, 11:47 AM
MSN lists a lot of junk and it seems unpossible to remove them from their index. My little website has a lot of pages indexed that are actually no pages...just internal links to some standalone scripts.

anon
08-03-2006, 08:04 PM
Content visible to registered users only.
well.. that definately isn't something i wanted to read ;((

hopefully they fix it.

mystickcal
08-04-2006, 02:18 AM
Okay thanks...so I got that I just create a file called php.ini using like notepad and put in the gzip line, but do I need to have anything else in the php.ini. If i just have that gzip thing in there it won't mess up anything else with my php files right? Just making sure because this is the first real time I've used php is with this directory. Sorry if this sounds stupid... :)

sofie77
08-16-2006, 09:12 PM
if i add the line in my index i get:

Warning: ob_start(): output handler 'ob_gzhandler' conflicts with 'zlib output compression' index.php on line 4

I asked my host already and i saw the php.ini...the compression is on and the level is 5. what i do wrong?

shadav
12-25-2006, 05:12 AM
Content visible to registered users only.


google does the same thing to me...i have a foamy fan site and it lists all of my flash files :rolleyes:

anyways lol thanks for the .htaccess trick...though it didn't seem to really speed up anything lol
I tested the loading speed with
Summit Media Spider Simulator (http://tools.summitmedia.co.uk/spider/)
my directory went from 2 seconds to 1 second :p but hey every little bit helps *and before ya say anything...yes i just started the directory, however i've got like 250 links to it...yeah yeah not much i guess comparitively :o

redgsr
01-02-2007, 04:26 AM
Is this Gzip mod the same as the Compress output: feature used on 3.1?

David
01-02-2007, 04:46 AM
Content visible to registered users only.

I would say yes for the most part.
The main thing I don't like about gzipping right now is MSN's search engine can't seem to read gzipped pages. Stupid I know, but what else can I say?

vignesh_natraj
01-06-2007, 10:13 AM
Content visible to registered users only.
are you 100% sure on this one or just using an0n's experience
should i implement it?

msolution
06-26-2007, 07:52 PM
What to say, i just had to ask them!

Content visible to registered users only.

(i put stars in the name so it doesnt get googled, and removed mine:p)

shadav
06-27-2007, 01:04 AM
thanks for that msolution :)

i think they may have lied though cuz i have Content visible to registered users only. in my .htaccess on my adult directory but yet it's still indexed by msn.

msolution
06-27-2007, 10:15 AM
Question?:
http://in.php.net/ob_gzhandler

says:All browsers are supported since it's up to the browser to send the correct header saying that it accepts compressed web pages. If a browser doesn't support compressed pages this function returns FALSE.

so ... does msnbot send these headers!, if it does, whats the issue!

M.

onelife
06-28-2007, 09:41 AM
Could the function to use gzip in our directories be modified to create static html pages in a cache. This would be very helpful for high traffic sites.

I've found this code but I can't get it to work with phpld

I've used this type of thing on other projects and it really made a different to the crawlability of the site and response times are just slashed to pieces.

Cheers,

Dave

dabfeed
08-28-2007, 09:21 PM
Dave, can you elaborate a little on your point about making a difference on the crawlability? Exactly how?

James
08-28-2007, 09:27 PM
msn chokes on it. If you enable it and your server is already trying to compress pages your going to get garbled text etc etc

IF you site is getting slammed and you can follow basic instructions on use I can cahce your site and speed it up to the point you think it is static.

jminscoe
08-29-2007, 04:06 AM
IMHO never compress I learned the hard way leave it where it is and just have Dawzz cache it

falsealarm
09-01-2007, 07:29 AM
What method does Dawzz use for caching? Is it on the database side?

jminscoe
09-01-2007, 02:07 PM
with mine I believe it was files as I am not sure as he has free reign in my directories if he needs to fix something pm him and he will let you know

shadav
09-01-2007, 03:43 PM
Content visible to registered users only.
:D :D him, boby, anon, VSDan, proprod :D :D they can all have free reign on my directories lolol

jminscoe
09-01-2007, 04:08 PM
Content visible to registered users only. so far the only ones have been Dawzz, an0n and Dargre but if I need the others I would use them as they are trusted:D

shadav
09-01-2007, 04:10 PM
oh sorry i forgot about Dargre :) *and of course David lol*
but anyways, i believe Dawzz uses files to cache with, but i could be wrong....whatever it is he does it has helped a lot on peoples sites...

falsealarm
09-01-2007, 05:52 PM
David had at one point mentioned query caching for some of the people on the forum. Can anybody elaborate on that?

James
09-02-2007, 03:03 AM
yeah that is what I am doing. Am I prepared to post a how to... not yet.

You can do it yourself by researching adodb caching or let me do it and you report back anything you run into problem wise. I truely dont think there are any :)

hazardouspunch
02-04-2008, 11:24 AM
My directory's load time decreased from 4 seconds to 0,38 seconds.This is amazing.Awesome! Well Done.

gustotelmy
04-02-2008, 11:49 AM
no problem dude :)

lol at least someone finds my mod still finds it helpful... they actually included it sometime back in phpld 2.x something (paid only i think) in the admin panel.

no offense but yahoo and msn suck at getting my pages no matter if i gzip or not. Google has no problem with gzipping whatsoever. I still use gzipping on most of my sites even non-phpld pages. Even joomla does too...

falsealarm
04-14-2008, 09:02 PM
James, any word on that adodb caching how-to giude? :)

James
04-14-2008, 09:42 PM
version 3.2?

3.3 is built in.