3

My website is loading large (~3mb) SVG file with jQuery. It takes quite a while therefore I decided to enable gzip compression. I have a hosting account with Bluehost which supports custom .htaccess files. Here is what I have tried to add to .htaccess file to enable compression without any success (I used Google's Page Speed for testing):

<IfModule mod_php5.c>
    php_value output_buffering "1"
    php_value output_handler ob_gzhandler
</IfModule>

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/xml text/plain text/css text/javascript application/x-javascript
</IfModule>

<IfModule mod_gzip.c>
    mod_gzip_on Yes
    mod_gzip_dechunk Yes
    mod_gzip_item_include file \.(html?|txt|xml|css|js|php|pl|gif|jpg|jpeg|png|swf)$
    mod_gzip_item_include handler ^cgi-script$
    mod_gzip_item_include mime ^text/.*
    mod_gzip_item_include mime ^application/x-javascript.*
    mod_gzip_item_exclude mime ^image/.*
    mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
3
  • 1
    In its present form this question is too localized (see Pro Webmasters FAQ). You need to check the installed Apache modules and contact your host for assistance if the modules you need are not installed or not performing as you expect.
    – danlefree
    Commented Aug 14, 2011 at 2:18
  • Sorry I didn't realized that the question can be too specific. I wanted to try to ask this question here because I already know what type of an answer ill get from tech support (they probably will say that modules are not available for me to configure). So I thought maybe some people here came up with workarounds or suggestions they could kindly share.
    – lanan
    Commented Aug 15, 2011 at 15:28
  • But I am gonna follow your advise and contact tech support.
    – lanan
    Commented Aug 15, 2011 at 15:28

4 Answers 4

3

I use the following in the .htaccess on my bluehost account (as recommended by a friend)

  <Files ~ "^[^\.]+$">
    ForceType application/x-httpd-php
    SetOutputFilter DEFLATE
  </Files>

  <FilesMatch "\.(js|css|html|htm|php|xml)$">
    SetOutputFilter DEFLATE
  </FilesMatch>

  ExpiresActive on
  ExpiresByType image/png "access plus 1 month"
  ExpiresByType image/gif "access plus 1 month"
  ExpiresByType image/jpeg "access plus 1 month"
  ExpiresByType text/css "access plus 1 month"
  AddType image/vnd.microsoft.icon .ico
  ExpiresByType image/vnd.microsoft.icon "access plus 3 months"
2
  • 2
    Hey thanks for your answer! Unfortunately it didn't work for me all of my .xml .js and .css files are still sent without any compression (i added your code to my .htaccess file in public_html). I guess mod_deflate is not always available on Bluehost. Im trying to contact them to find out the answer.
    – lanan
    Commented Aug 15, 2011 at 15:22
  • bluehostforum.com/… On the second page is a support response that they will not consider enabling it. Am guessing, although an old thread, it is still policy.
    – pritaeas
    Commented Aug 16, 2011 at 7:18
1

An update to this question, I recently spoke to BlueHost who told me the following:

The way gzip works is that when certain criteria are reached with the server resources, gzip will be enabled and start compressing the sites as needed. Even with the code in the .htaccess file, that's not actually something that you will be able to configure on the account.

But from my findings "as needed" translated to "never". If you really want to GZIP you content (and deliver it quickly) I suggest you look at using Cloudflare as a CDN. Bluehost are a hosting partner of theirs, so it's trivial to set up.

0

I just added gzip compression via the .htaccess file on Bluehosts's WordPress Hosting. By default, it had the source html/php and CSS files gzipped. Adding this code from BlueHost's WordPress optimization tips article enabled gzip for JS files, images, etc:

<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE image/gif image/png image/jpeg image/x-icon application/pdf application/javascript application/x-javascript text/plain text/html text/css text/x-component text/xml application/json
</ifmodule>
0

Bluehost doesn't offer compressions for .js or .css files (compression only works on .html or .php files) so you will not get that to work on one of their boxes, even with php.ini or .htaccess changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.