karlfranz Posted May 2, 2004 Posted May 2, 2004 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! Quote
borfast Posted May 2, 2004 Posted May 2, 2004 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. Quote
karlfranz Posted May 2, 2004 Author Posted May 2, 2004 I don't know PHP,but some of my files are PHP files. Quote
borfast Posted May 2, 2004 Posted May 2, 2004 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 Quote
DarqFlare Posted May 2, 2004 Posted May 2, 2004 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... Quote
karlfranz Posted May 2, 2004 Author Posted May 2, 2004 Hey,there's some text in the .htaccess, where should the code php_value output_handler ob_gzhandler put? Quote
arvind Posted May 2, 2004 Posted May 2, 2004 It should be ok if you put it anywhere just make sure its on its own line but I think anywhere in the .htaccess is ok ! Quote
borfast Posted May 2, 2004 Posted May 2, 2004 (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 Thumbs Up Edited May 2, 2004 by TCH-Raul Quote
arvind Posted May 2, 2004 Posted May 2, 2004 Some more tips here http://www.totalchoicehosting.com/forums/i...?showtopic=8918 they also discuss the php gzip ocmpression. Do not add the line of code talked about there as well because that would be calling the function twice Quote
LisaJill Posted May 2, 2004 Posted May 2, 2004 Are there any considerations when using this to affect files that are built on the fly from mysql? Quote
DarqFlare Posted May 2, 2004 Posted May 2, 2004 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? Quote
LisaJill Posted May 2, 2004 Posted May 2, 2004 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. Quote
borfast Posted May 2, 2004 Posted May 2, 2004 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. Quote
LisaJill Posted May 2, 2004 Posted May 2, 2004 Got it, thank you Raul. =) I'm not slashdot; if I'm ever that successful I'll be very happy, though? Quote
borfast Posted May 2, 2004 Posted May 2, 2004 (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?... 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. Edited May 2, 2004 by TCH-Raul Quote
LisaJill Posted May 2, 2004 Posted May 2, 2004 Ya, but if I ever turn into slashdot I'll get a fully managed, dedicated server, no hesitation. *grins* Quote
arvind Posted May 3, 2004 Posted May 3, 2004 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 it should be ok ! I've been running gzip since the start of the other thread and its excellent for me 74% savings Quote
karlfranz Posted May 3, 2004 Author Posted May 3, 2004 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. Quote
borfast Posted May 3, 2004 Posted May 3, 2004 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 Quote
arvind Posted May 3, 2004 Posted May 3, 2004 As mentioned before http://www.desilva.biz/gzip-test.php Good site to test out the compression ! Quote
section31 Posted October 3, 2004 Posted October 3, 2004 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. Quote
borfast Posted October 3, 2004 Posted October 3, 2004 (edited) I think it should behave recursively, as you mentioned, but as strange as it may seem, in my site, only the files in the root directory are getting compressed Give it a try and check the result on this site: http://www.desilva.biz/gzip-test.php Edited October 3, 2004 by TCH-Raul Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.