eCasper Posted October 22, 2010 Share Posted October 22, 2010 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 More sharing options...
Manjunath D S Posted October 22, 2010 Share Posted October 22, 2010 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 More sharing options...
eCasper Posted October 22, 2010 Author Share Posted October 22, 2010 Hi Thnx for the reply!I'm sorry! Each of the methods didn't work out for me. It gives me Internal Server Error. Link to comment Share on other sites More sharing options...
Manjunath D S Posted October 22, 2010 Share Posted October 22, 2010 Can you post the error message? Error message could tell us the real reason behind the problem. Link to comment Share on other sites More sharing options...
eCasper Posted October 22, 2010 Author Share Posted October 22, 2010 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/plainAddOutputFilterByType DEFLATE text/htmlAddOutputFilterByType DEFLATE text/xmlAddOutputFilterByType DEFLATE text/cssAddOutputFilterByType DEFLATE application/xmlAddOutputFilterByType DEFLATE application/xhtml+xmlAddOutputFilterByType DEFLATE application/rss+xmlAddOutputFilterByType DEFLATE application/javascriptAddOutputFilterByType DEFLATE application/x-javascriptI get the same error Error: /.htaccess: Invalid command 'AddOutputFilterByType', perhaps mis-spelled or defined by a module not included in the server configuration Link to comment Share on other sites More sharing options...
Manjunath D S Posted October 22, 2010 Share Posted October 22, 2010 It seems the mod_deflate module is not loaded on apache web server. I suggest to open a support ticket on your godaddy account. They would be able to rectify the load module issue. Link to comment Share on other sites More sharing options...
richardmoore Posted October 22, 2010 Share Posted October 22, 2010 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 More sharing options...
eCasper Posted October 22, 2010 Author Share Posted October 22, 2010 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 swfAddType 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.1Thanks in Advance! Link to comment Share on other sites More sharing options...
eCasper Posted October 25, 2010 Author Share Posted October 25, 2010 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 More sharing options...
Manjunath D S Posted October 25, 2010 Share Posted October 25, 2010 Enter your site URL in at http://redbot.org/? to check the 'content negotiation' results. It will show if the gzip compression is active. Or check content ecncoding attribute in the result. Link to comment Share on other sites More sharing options...
eCasper Posted October 25, 2010 Author Share Posted October 25, 2010 Here is the result. does it show anything about gzip?? Link to comment Share on other sites More sharing options...
eCasper Posted October 27, 2010 Author Share Posted October 27, 2010 I decided to leave godaddy! I think that's the only way I can get this feature working! Link to comment Share on other sites More sharing options...
vertiworks Posted November 11, 2010 Share Posted November 11, 2010 Hello. It seems i'm having the same problem.What server did you go sir which you are able to do it? Link to comment Share on other sites More sharing options...
eCasper Posted November 12, 2010 Author Share Posted November 12, 2010 I prefer Hostgator, most probably in this December I'll move things up there!! Link to comment Share on other sites More sharing options...
eCasper Posted November 15, 2010 Author Share Posted November 15, 2010 As far as I know it depends on your hosting provider! Link to comment Share on other sites More sharing options...
ALMAJ Posted February 25, 2014 Share Posted February 25, 2014 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). Compressing http://www.tekcenter...894ca5515689.jscould save 152.2KiB (69% reduction). Compressinghttp://www.tekcenter...b9d80ce_all.css could save 80.7KiB (82% reduction). Compressing http://www.tekcenter...pluginDetect.js could save 14.9KiB (65% 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now