jordanwb Posted September 3, 2008 Share Posted September 3, 2008 How would I go about implementing gzip compression in my PHP scripts? Also do I need to compile PHP with any particular USE flags on my Gentoo install? Quote Link to comment https://forums.phpfreaks.com/topic/122572-implimenting-gzip-compression-in-a-webpage/ Share on other sites More sharing options...
Mchl Posted September 3, 2008 Share Posted September 3, 2008 See output buffering functions Quote Link to comment https://forums.phpfreaks.com/topic/122572-implimenting-gzip-compression-in-a-webpage/#findComment-632882 Share on other sites More sharing options...
jordanwb Posted September 3, 2008 Author Share Posted September 3, 2008 So I'd put this before any output: ob_start("ob_gzhandler"); What about after I ouput stuff? Do I call ob_end_flush(); I remember from MyBB that there was an option to control how hard the compressor should try. Also what about cookies? Quote Link to comment https://forums.phpfreaks.com/topic/122572-implimenting-gzip-compression-in-a-webpage/#findComment-632886 Share on other sites More sharing options...
Mchl Posted September 3, 2008 Share Posted September 3, 2008 There's also zlib.output_compression which lets you set compression level. Quote Link to comment https://forums.phpfreaks.com/topic/122572-implimenting-gzip-compression-in-a-webpage/#findComment-632893 Share on other sites More sharing options...
discomatt Posted September 3, 2008 Share Posted September 3, 2008 Cookies will be in the header, so output compression shouldn't affect them. Why not have compression done automatically if you're building your own version of PHP http://php.net/manual/en/zlib.configuration.php#ini.zlib.output-compression Quote Link to comment https://forums.phpfreaks.com/topic/122572-implimenting-gzip-compression-in-a-webpage/#findComment-632896 Share on other sites More sharing options...
jordanwb Posted September 3, 2008 Author Share Posted September 3, 2008 The thing is I don't want to be always compressed. I'm designing my Site Content Manager to support Plugins. There will be a compression plugin featuring a compression algorithm. Also the compression amount will be on a per user basis. If one wants high compression, then higher compression will be attempted. I checked make.conf and PHP was compiled with zlip support. Quote Link to comment https://forums.phpfreaks.com/topic/122572-implimenting-gzip-compression-in-a-webpage/#findComment-632923 Share on other sites More sharing options...
discomatt Posted September 3, 2008 Share Posted September 3, 2008 ini_set may work here, I'm not entirely sure. You should check it out Quote Link to comment https://forums.phpfreaks.com/topic/122572-implimenting-gzip-compression-in-a-webpage/#findComment-632925 Share on other sites More sharing options...
jordanwb Posted September 3, 2008 Author Share Posted September 3, 2008 I found this: http://www.desilva.biz/php/zlib.html Quote Link to comment https://forums.phpfreaks.com/topic/122572-implimenting-gzip-compression-in-a-webpage/#findComment-632928 Share on other sites More sharing options...
phpoet Posted September 3, 2008 Share Posted September 3, 2008 I have used Devin Doucette's Archive class before and found that it worked really well. You can <a href="http://www.phpclasses.org/browse/package/945.html">get it here</a>. Quote Link to comment https://forums.phpfreaks.com/topic/122572-implimenting-gzip-compression-in-a-webpage/#findComment-632951 Share on other sites More sharing options...
Mchl Posted September 3, 2008 Share Posted September 3, 2008 This class isn't exactly what jordanwb is looking for. It allows creating end decompressing zip/tar/gzip archives, while jordanwb wants to compress web pages as they're sent from server to browser. Quote Link to comment https://forums.phpfreaks.com/topic/122572-implimenting-gzip-compression-in-a-webpage/#findComment-632956 Share on other sites More sharing options...
jordanwb Posted September 3, 2008 Author Share Posted September 3, 2008 while jordanwb wants to compress web pages as they're sent from server to browser. Precisely. Quote Link to comment https://forums.phpfreaks.com/topic/122572-implimenting-gzip-compression-in-a-webpage/#findComment-632975 Share on other sites More sharing options...
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.