I have found a couple of tutorials on how to enable gzip, but nothing seems to be working for me, so my question is how do i enable gzip. I am on a shared Dreamhost hosting server, It is running PHP version 5.2, and Apache, from the php info i have found this line, maybe this could help?
zlib
ZLib Support enabled
Stream Wrapper support compress.zlib://
Stream Filter support zlib.inflate, zlib.deflate
Compiled Version 1.2.3.3
Linked Version 1.2.3.3
Directive Local Value Master Value
zlib.output_compression Off Off
zlib.output_compression_level -1 -1
zlib.output_handler no value no value
I have also found this line
_SERVER["HTTP_ACCEPT_ENCODING"] gzip, deflate
I don't know if that has anything to do with it. But that is my first question, secondly, i have dropbox, hosting a javscript file, and I am wondering is it possible to have that file gzipped, It is not being transfered compressed, so is ther any way to do so?
All I had to do to enable the encoding at the Apache level is
this will make the server do the necessary request header check, compress, send related headers
you can also do that in your PHP files before the
ob_start()
And to make Apache compress the static resources (e.g: .js files , .css files) do as Kamlesh did in his answer
Have you tried with ob_gzhandler?
php manual
Tip: Sometimes is pretty tricky to detect if the web is send compressed or not, i use firefox's firebug plugin, i tested a php file without compression and with compression and compare the size, in my case, the difference was 1mb (non compressed) and 56kb compressed.
Or in your .htaccess
The compression can be done in two ways.
Reference: http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/
## First of all you have to make changes in WHM (server) setting to enable Gzip. After that make changes in cPanel setting ##
In Apache, enabling output compression is fairly straightforward. Add the following to your .htaccess file:
Source : http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/
In the official wiki of Dreamhost they enable this by modifying an htaccess:
With a quick search on Google you can come up with another thread on Stackoverflow an in a third party site addressing this issue.