I hope that this is the right place to post this....Problem:
I decided that I would like to speed up our Moodle installation using mod_gzip compression. I decided to follow the instructions below exactly. I was ecstatic to find out that the site passed the GIDZipTest but was horrified to see that many pictures were missing. Now, it was every picture was missing. Background images, moodle logos were still there but the pictures that had been uploaded via Moodle were missing. I clicked on some excel files and then some PowerPoints only to find out that they to were gone. Now, "gone" may not be the right word because if I right-clicked where the image should have been (in firefox if it matters) and went to 'view image' I was sometimes greeted with all manner of strange symbols rather than the image. Also, when I went to open an excel file it would open excel but the file would be empty - no data to be seen. Same thing happened with PowerPoints. I immediatly went and checked via FTP the integrity of the files on the server (/public_html/uploaddata/213/example.ppt) and luckily everything was ok. I have undone the damage and everything seems to be fine....but I really would like this mod_gzip to work. Could anyone explain why the images would disapear and why uploaded resource files (PowerPoints, excel files etc.,) seemed to be corrupted in some way?
Bellow are the instructions I followed exaclty:
As you may already know, I am a speed and performance junkie. When it comes to website management, nothing makes me feel better than a website that loads fast! If this can be done with dynamic content then it is something to admire.
One feature that I have implemented on the HostMonster-hosted website that I manage is GZIP compression. For a detailed description on GZIP you can read this very interesting article on BetterExplained.com. In short, however, what GZIPing does is that it compresses downloaded files which essentially saves a bit on server bandwidth and slightly speeds up client-side viewing. Although you can use some PHP to call for compression on the fly for specific files it is much easier to simply activate compression from the web server. Here, I will show you how you can activate it for a website hosted with HostMonster. This should also work if you are on another shared hosting provider that runs under Linux and Apache. You need access to your php.ini file and .htaccess file.
- Check to make sure that your hosting environment can utilize GZIP. If you host your website with HostMonster this feature is supported. On other web hosts you will need to execute phpinfo(), then ensure that ‘gzip‘ is listed under _ENV["HTTP_ACCEPT_ENCODING"] and HTTP_ACCEPT_ENCODING to verify.
- Once you have verified that the feature is supported go ahead and create a single php.ini file that can be applied to all subdirectories within your /htdocs or /public_html directory. On HostMonster-hosted, just go to the ‘Software/Services’ section of your cPanel and click on ‘PHP Config’. Select ‘PHP5 (single php.ini)’ and save the change. Then, click on “Install PHP.ini master file”. Rename the “php.ini.default” file to php.ini in your public web files directory. If you had one there before, delete it before renaming the new php.ini file.
- Open the php.ini file in a simple text editor and navigate to the section that deals with output_handler. Set the value equal to ob_gzhandler and ensure that any values for zlib are disabled or commented out. Afterward, save and update the php.ini file on the server.
output_handler = ob_gzhandler
zlib.output_compression = Off
- Open the .htaccess file that is located in your public web files directory (usually the same location as you php.ini file). Add the following statements to invoke the use of the relevant Apache module for compressing your files listed and save.
mod_gzip_item_include file \.(html?|txt|css|js|php|pl|jpg|png|gif)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
5. Now try accessing your website through your browser. After about a minute or two, run the GIDZipTest for your website. If your site is reported to be serving compressed pages then you are finished!
I have been able to achieve compression as high as 70% as reported by the GIDZipTest page. I hope it works for you and your site sees a bit more improvement when it comes to loading time. There are still a few other things that can be done in terms of making things faster, but those will come later. Happy tweaking!
WARNING: Do not attempt to enable GZIP using these steps while you have ZLIB enabled. Use one or the other. Again, HostMonster-hosted supports ZLIB but, just like GZIP, it is not enabled by default.