Jump to content

Recommended Posts

Posted

Hello,

I have heard if I changed some code in the file ".htaccess" of a folder,then all the php files in the folder will be compressed,this can be applied by using the following code,

php_value output_handler ob_gzhandler

however,as I don't know PHP and coding at all so I don't exactly understand how to do this,can someone help me?

Thanks!

Posted

Karl, adding that to .htaccess will only help you if you have some PHP stuff on your website. If you don't use PHP at all, it's useless. :dance:

Posted

In that case, you just need to add that line to .htaccess under the public_html folder (if .htaccess doesn't exist, create the file).

 

That's all there is to it.

 

All PHP files will be transparently compressed on the server and sent to the client. Try visiting this site:

http://www.desilva.biz/gzip-test.php

then add the .htaccess stuff and visit the site again. You should be able to note the difference :dance:

Posted

I'm not exactly in-the-know on this PHP compression... What exactly does it do and what is the process?

 

My websites are all PHP-driven, maybe I'll activate this...

Posted (edited)

Arvind is right, it shouldn't matter where you put that code, as long as it's in a line alone.

 

Robert, that line activates PHP's transparent gzip compression of code. It means that everthing PHP outputs is compressed by gzip, meaning it will eat less bandwidth and be transfered faster to your visitors. Good stuff :dance: Thumbs Up

Edited by TCH-Raul
Posted

Yeah, I'm with Lisa here...

 

phpBB can use GZIP compression, so I imagine it's good with MySQL-driven pages, but let's get the word here.

 

Are there any real drawbacks to using it?

Posted

I've thrown this in my .htaccess file; I'm not noticing anything wrong, and the site is lightning fast at that. But I'm just worried about processor load etc. I don't have an incredibly busy site so maybe it's not a problem? Still, with it pounding the mysql database maybe between roundtripping and gzipping...

 

Just want to make sure all is well. ;)

Posted

GZipping the output of PHP shouldn't be a big load on the server. Well, unless you're running Slashdot, of course ;)

 

About the MySQL question, the idea is: any text that PHP outputs will get compressed. If you use PHP to fetch data from MySQL and then output that data, it will be compressed, unless it's an image, or something like that. Text files are compressed. Other types of files are not.

Posted (edited)
Got it, thank you Raul. =) I'm not slashdot; if I'm ever that successful I'll be very happy, though?

Lisa: it depends. Are you on a shared server?... :dance: ;)

 

Robert: only if you think your website will cause heavy load on the server. For a modest site, I don't think there will be any problem. I have it activated on all my sites (one of them has hundreds of visits every day) and never had any problem. :dance:

Edited by TCH-Raul
Posted

It was discussed in the other thread that gzipping causes high load of shared servers if the content of your files are large. Correct me if I"m wrong and that is why one of the staff said that mod_gzip wasn't installed. He also said that if your site isn't large volume and isn't slashdot :P it should be ok ! I've been running gzip since the start of the other thread and its excellent for me 74% savings :dance:

Posted

For my own experience(may me wrong and useless),

this method may not be very good for small size pages,

it's because the compression itself takes a few time(0.X seconds) to process,if your page loaded very fast(within 1 second),you will not benefit so much from it.

Of cource,this function is excellent for heavy text files such as forum.

Posted

Well, you could always write a little script to see how big the page is and, based on that size, decide whether or not to use compression :dance:

  • 4 months later...
Posted

i know this thread is old...lets see if someone can help me...

 

I noticed by adding that line

"php_value output_handler ob_gzhandler"

to the .htaccess file it does it to all the directories under it as well. Is there anyway to just restrict it to only that directory.

 

if there isn't I suppose I could just put ob_gzhandler on every file i need it in.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...