sunreader Posted March 27, 2014 Share Posted March 27, 2014 Hi, I noticed that by default, prestashop content is not being gzip compressed. My question is: why? adding this to the .htaccess file, improves the loading quite a lot. # compress text, HTML, JavaScript, CSS, and XMLAddOutputFilterByType 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-javascript# remove browser bugsBrowserMatch ^Mozilla/4 gzip-only-text/htmlBrowserMatch ^Mozilla/4\.0[678] no-gzipBrowserMatch \bMSIE !no-gzip !gzip-only-text/htmlHeader append Vary User-Agent Source: http://gtmetrix.com/enable-gzip-compression.html Here's my sites result before and after gzip compression: No gzip: gzip: Link to comment Share on other sites More sharing options...
bellini13 Posted March 27, 2014 Share Posted March 27, 2014 gzip compression first needs to be enabled on your hosting web server configuration (apache, nginx etc..) With that enabled, then go to you back office, advanced preferences > performance section, and make sure 'apache optimization' is enabled. Then Prestashop will add the following to your .htaccess file. Note: This likely only works with apache, since nginx has different configuration settings and normally does not read the htaccess files. You can also alter/override the Tools::generateHtaccess function to add or remove anything specific to your hosting environment. <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\" ExpiresByType image/svg+xml \"access plus 1 year\" ExpiresByType image/vnd.microsoft.icon \"access plus 1 year\" ExpiresByType application/font-woff \"access plus 1 year\" ExpiresByType application/x-font-woff \"access plus 1 year\" ExpiresByType application/vnd.ms-fontobject \"access plus 1 year\" ExpiresByType font/opentype \"access plus 1 year\" ExpiresByType font/ttf \"access plus 1 year\" ExpiresByType font/otf \"access plus 1 year\" ExpiresByType application/x-font-ttf \"access plus 1 year\" ExpiresByType application/x-font-otf \"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> Link to comment Share on other sites More sharing options...
wakabayashi Posted July 9, 2014 Share Posted July 9, 2014 Thanks for this Tips. I am a newbie on this topic. I activated everything (CCC) in the admin. I can see clearly improvements when I test on gtmetrix. But it doesnt make the gzip properly. Some files are done (or at least gtmetrix doesnt show them anymore). But gtmetrix show me: Compressing the following resources with gzip could reduce their transfer size by 236.9KiB (72% reduction). Compressing http://schiendorfer.info/ps-theme/themes/chesspoint/cache/v_0_1d0a109ca5d27dcafa0e26d1424a5c55.js could save 155.7KiB (69% reduction). Compressing http://schiendorfer.info/ps-theme/themes/chesspoint/cache/v_0_da64289e48ec3d36f3d05148f0667634_all.css could save 48.7KiB (79% reduction). Compressing http://schiendorfer.info/ps-theme/de/ could save 32.5KiB (80% reduction). Any idea how I can make this work? If its really possible to save 236.9KB, this would be amazing. What would you say is a good KB-Size for the prestashop Homepage? Link to comment Share on other sites More sharing options...
bellini13 Posted July 9, 2014 Share Posted July 9, 2014 I'm not sure why the .js and .css files are not being compressed, I would have to assume that your apache/nginx settings are not configured to compress those file extensions. 236KB is not a lot in this day and age. It may actually take more time to compress these 2 files then it would be to download them to the clients browser The third file i assume is html content of the home page, so again I would have to assume that your webserver is not configured to compress .html or .php file output Link to comment Share on other sites More sharing options...
DARKF3D3 Posted September 11, 2014 Share Posted September 11, 2014 I have the same problem, js and css files are not gzipped, this is my .htaccess file: # ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again # .htaccess automaticaly generated by PrestaShop e-commerce open-source solution # http://www.prestashop.com - http://www.prestashop.com/forums <IfModule mod_rewrite.c> <IfModule mod_env.c> SetEnv HTTP_MOD_REWRITE On </IfModule> RewriteEngine on RewriteRule . - [E=REWRITEBASE:/] RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L] # Images RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L] RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L] RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L] 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/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L] 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/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L] RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L] RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L] # AlphaImageLoader for IE and fancybox RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L] # Dispatcher RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L] </IfModule> AddType application/vnd.ms-fontobject .eot AddType font/ttf .ttf AddType font/otf .otf AddType application/x-font-woff .woff <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" ExpiresByType image/svg+xml "access plus 1 year" ExpiresByType image/vnd.microsoft.icon "access plus 1 year" ExpiresByType application/font-woff "access plus 1 year" ExpiresByType application/x-font-woff "access plus 1 year" ExpiresByType application/vnd.ms-fontobject "access plus 1 year" ExpiresByType font/opentype "access plus 1 year" ExpiresByType font/ttf "access plus 1 year" ExpiresByType font/otf "access plus 1 year" ExpiresByType application/x-font-ttf "access plus 1 year" ExpiresByType application/x-font-otf "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> #If rewrite mod isn't enabled ErrorDocument 404 /index.php?controller=404 # ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again Link to comment Share on other sites More sharing options...
bellini13 Posted September 11, 2014 Share Posted September 11, 2014 this likely means one of a few things 1) your web server is not configured to perform gzip, so you would need to work with your host to enable this. 2) the mod_deflate and/or mod_filter extensions are not enabled. If I had to take a guess, I suspect those 2 extensions are disabled... Link to comment Share on other sites More sharing options...
DARKF3D3 Posted September 11, 2014 Share Posted September 11, 2014 (edited) But it's strange because on old theme with PS1.4.9 i get a Page Speed Grade near to 90%, with gzip at the best score. I try to re-ask to my hosting provider. EXIT: You were right, mod_deflate and mod_filter was disables. Now i get Page Speed Grade: 87% and YSlow Grade: 86%. Edited September 11, 2014 by DARKF3D3 (see edit history) 1 Link to comment Share on other sites More sharing options...
bellini13 Posted September 11, 2014 Share Posted September 11, 2014 Good Stuff! Link to comment Share on other sites More sharing options...
jhd Posted September 11, 2014 Share Posted September 11, 2014 (edited) Hello, @sunreader: I just checked and it is not enabled. http://www.gidnetwork.com/tools/gzip-test.php Results for: http://sunreader.dk Web page compressed? No Compression type? none Size, Markup (bytes) 82,887 Size, Compressed (bytes) 82,887 Compression % 0.0 Best regards Edited September 11, 2014 by jhd (see edit history) Link to comment Share on other sites More sharing options...
Compolux Posted November 18, 2014 Share Posted November 18, 2014 (edited) For me work this solution. If your web server is Apache, and if the mod_deflate module is enabled on it, the following method is the easiest way to get compression enabled for your entire web site. You just insert something like this to the .htaccess file in your web document root folder: <IfModule deflate_module> # Enable compression for the following file types. AddOutputFilterByType \ DEFLATE \ application/javascript \ text/css \ text/html \ text/javascript \ text/plain \ text/xml </IfModule> PS 1.6. Edited November 18, 2014 by Compolux (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts