Jump to content

[Solved] - how to enable gzip with godaddy?


eCasper

Recommended Posts

I'm using linux based hosting at godaddy. When I was asking some support for enabling gzip feature in ma web server, godaddy suggested me adding following line of code in very top of ma each web pages.

<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?>

but i was expecting something like editing the .htaccess and enabling the feature rather modify each web pages in my site.

Can anybody tell me that is it possible to enable gzip feature by editing .htaccess file?

I've already tried some suggestion which are found in this forum but none of them are worked for me.

Thanks in advance!

Link to comment
Share on other sites

You can add following code into .htaccess.

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# Or, compress certain file types by extension:

SetOutputFilter DEFLATE



Read this article for detailed explaination and tools to check the compression
http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/

Link to comment
Share on other sites

Hi,

Here is what I'm exactly getting.

Command:


SetOutputFilter DEFLATE


Error: /.htaccess: Invalid command 'SetOutputFilter', perhaps mis-spelled or defined by a module not included in the server configuration


Also for the command:

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

I get the same error

Error: /.htaccess: Invalid command 'AddOutputFilterByType', perhaps mis-spelled or defined by a module not included in the server configuration

31909_T6fGs88wODZaKRtjesxP_t

Link to comment
Share on other sites

This article is to address more than the gzip compression. Most of this is mod_deflate to compress the output of the syntax, but the fragment is used to send mod_expres. Expires header, two totally different things. It's very important to include lines corresponding to the browser, as they say mod_deflate do not send compressed content to IE version 6 and below. They Apache users to define their own, make sure that mod_expires mod_deflate and forever! save bandwidth, save the world.

Link to comment
Share on other sites

Godaddy replies:

You may need to define the MIME type on your hosting account to allow this error not to display. You can configure MIME types on your Linux hosting account using a .htaccess file. When you configure MIME types in your .htaccess file, you associate file types with a specific application or action.
For example:

AddType application/x-shockwave-flash swf

AddType specified you are adding a new mime type (file type).

application/x-shockwave-flash is the actual mime parameter specs.

swf is the extension of the file type.

NOTE: HTML and PHP MIME types can only be modified on hosting accounts running Hosting Configuration 2.0 and above. For information about upgrading to Hosting Configuration 2.0, see How do I upgrade my hosting account to run Hosting Configuration 2.0?


You may want to do a search on your favorite search engine or consult with a community forum online, such as w3schools.com or apache.org as other users may have encountered similar problem(s) in the past and may offer helpful solutions.


But I don't understand what I really should do. Please advise me on this. I'm having Hosting Configuration 2.1

Thanks in Advance!
Link to comment
Share on other sites

I have added following piece of code to my .httaccess file

mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ 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.


But it does seem gzip activated for my site yet. anyhelp???

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 years later...

How can I enable compression to themes/default/cache?
this is what i get from PageSpeed Insights and gtmetrix.com:

Compressing the following resources with gzip could reduce their transfer size by 247.8KiB (73% reduction).

My prestashop version is: 1.5.6.2 (Default theme)

 

my current .htaccess code is this:

<IfModule mod_rewrite.c>
<IfModule mod_env.c>
SetEnv HTTP_MOD_REWRITE On
</IfModule>

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.tekcenter.pt$
RewriteRule . - [E=REWRITEBASE:/store/]
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url= [QSA,L]

# Images
RewriteCond %{HTTP_HOST} ^www.tekcenter.pt$
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p//jpg [L]
RewriteCond %{HTTP_HOST} ^www.tekcenter.pt$
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p///jpg [L]
RewriteCond %{HTTP_HOST} ^www.tekcenter.pt$
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p////$1jpg [L]
RewriteCond %{HTTP_HOST} ^www.tekcenter.pt$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p////$4/$1jpg [L]
RewriteCond %{HTTP_HOST} ^www.tekcenter.pt$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p////$4/$5/$1jpg [L]
RewriteCond %{HTTP_HOST} ^www.tekcenter.pt$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p////$4/$5/$6/$1jpg [L]
RewriteCond %{HTTP_HOST} ^www.tekcenter.pt$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p////$4/$5/$6/$7/$1jpg [L]
RewriteCond %{HTTP_HOST} ^www.tekcenter.pt$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p////$4/$5/$6/$7/$8/$1jpg [L]
RewriteCond %{HTTP_HOST} ^www.tekcenter.pt$
RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/jpg [L]
RewriteCond %{HTTP_HOST} ^www.tekcenter.pt$
RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/jpg [L]
# AlphaImageLoader for IE and fancybox
RewriteCond %{HTTP_HOST} ^www.tekcenter.pt$
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/ [L]

# Dispatcher
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{HTTP_HOST} ^www.tekcenter.pt$
RewriteRule ^.*$ - [NC,L]
RewriteCond %{HTTP_HOST} ^www.tekcenter.pt$
RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
</IfModule>


<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
ExpiresByType image/x-icon "access plus 1 year"
</IfModule>


FileETag INode MTime Size
<IfModule mod_deflate.c>
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/x-javascript
</IfModule>
</IfModule>   

Best regards.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...