: Enable gzip compression on Bluehost? 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
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>
More posts by @Heady270
4 Comments
Sorted by latest first Latest Oldest Best
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>
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.
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.
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"
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.