Spidersiteme Posted July 28, 2013 Share Posted July 28, 2013 Hey everyone somthing really usfull and handy to speed up your site caching and compressing Just add the codes to your htacces file. also if you need help let me know Add to .htaccess: Header unset Pragma FileETag None Header unset ETag Cache-Control and Expires headers <FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf|pdf|flv|mp3)$"> <IfModule mod_expires.c> ExpiresActive on ExpiresDefault "access plus 14 days" Header set Cache-Control "public" </IfModule> </FilesMatch> <FilesMatch "\.(html|htm|xml|txt|xsl)$"> Header set Cache-Control "max-age=7200, must-revalidate" </FilesMatch> Add to .htaccess: Gzip compression with mod_deflate module <IfModule mod_mime.c> AddType application/x-javascript .js AddType text/css .css </IfModule> <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/javascript <IfModule mod_setenvif.c> BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html </IfModule> <IfModule mod_headers.c> Header append Vary User-Agent env=!dont-vary </IfModule> </IfModule> What this code does it activate compression of all files except these files archives, images, multimedia files, etc. SetOutputFilter DEFLATE <IfModule mod_setenvif.c> SetEnvIfNoCase Request_URI \.(?:rar|zip)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.(?:gif|jpg|png)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.(?:avi|mov|mp4)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary </IfModule> Sorce COde from howtounix.info 9 Link to comment Share on other sites More sharing options...
generalexperts Posted August 12, 2013 Share Posted August 12, 2013 (edited) I did what was mentioned above. And I think it works, but not by much. My GZIP compression shows it's very slow by looking at Gtmetrix.com How would I compress the rest? Compressing http://www.my-store.com/themes/shop/cache/51953d6b556cf09905855358523a9643.js could save 104.5KiB (69% reduction). Compressing http://www.my-store.com/themes/shop/cache/3441416999aa82604333e42f1d7fea97_all.css could save 57.6KiB (82% reduction). Compressing http://cdn.dev.skype.com/uri/skype-analytics.js could save 33.7KiB (64% reduction). Compressing http://www.my-store.com/modules/lofadvancecustom//tmpl/default/assets/fonts/helveticaneue.ttf could save 25.8KiB (47% reduction). Compressing http://www.my-store.com/modules/lofadvancecustom//tmpl/default/assets/fonts/vni-helve-condense.ttf could save 19.6KiB (47% reduction). Compressing http://cdn.dev.skype.com/uri/skype-uri.js could save 15.8KiB (76% reduction). Compressing http://www.my-store.com/modules/addshoppers/static/css/shop.css could save 264B (55% reduction). Edited August 13, 2013 by generalexperts (see edit history) 1 Link to comment Share on other sites More sharing options...
zeisei Posted February 2, 2014 Share Posted February 2, 2014 Spidersiteme, Thank you for the info. I did that and the compression/speed grading of google increase from 45/100 to 78/100 (ps1.5.4.1). Thank you. Link to comment Share on other sites More sharing options...
Hardwell Posted February 13, 2014 Share Posted February 13, 2014 how use gzip on the files in theme/default/cache ? 2 Link to comment Share on other sites More sharing options...
ALMAJ Posted February 25, 2014 Share Posted February 25, 2014 how use gzip on the files in theme/default/cache ? +1 Link to comment Share on other sites More sharing options...
ALMAJ Posted February 25, 2014 Share Posted February 25, 2014 (edited) Hey everyone somthing really usfull and handy to speed up your site caching and compressing Just add the codes to your htacces file. also if you need help let me know Add to .htaccess: Header unset Pragma FileETag None Header unset ETag Cache-Control and Expires headers <FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf|pdf|flv|mp3)$"> <IfModule mod_expires.c> ExpiresActive on ExpiresDefault "access plus 14 days" Header set Cache-Control "public" </IfModule> </FilesMatch> <FilesMatch "\.(html|htm|xml|txt|xsl)$"> Header set Cache-Control "max-age=7200, must-revalidate" </FilesMatch> Add to .htaccess: Gzip compression with mod_deflate module <IfModule mod_mime.c> AddType application/x-javascript .js AddType text/css .css </IfModule> <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/javascript <IfModule mod_setenvif.c> BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html </IfModule> <IfModule mod_headers.c> Header append Vary User-Agent env=!dont-vary </IfModule> </IfModule> What this code does it activate compression of all files except these files archives, images, multimedia files, etc. SetOutputFilter DEFLATE <IfModule mod_setenvif.c> SetEnvIfNoCase Request_URI \.(?:rar|zip)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.(?:gif|jpg|png)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.(?:avi|mov|mp4)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary </IfModule> Sorce COde from howtounix.info 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) Best regards. Edited February 25, 2014 by majority (see edit history) 1 Link to comment Share on other sites More sharing options...
Trip Posted February 26, 2014 Share Posted February 26, 2014 @generalexperts - the response time of your store is slow in general. I would test if there different cache settings if you can get out more or change hosting. Don't ask me why but with my theme disabling Minify HTML after "smarty compile" execution and Keep inline JavaScript in HTML as original made a huge difference in response time. Greetz, Trip Link to comment Share on other sites More sharing options...
HavanA Posted March 3, 2014 Share Posted March 3, 2014 Thanks Spidersiteme! My score went from 88% to 94% on pagespeed. I only added this at the bottom of the htaccess file: <IfModule mod_mime.c> AddType application/x-javascript .js AddType text/css .css </IfModule> <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/javascript <IfModule mod_setenvif.c> BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html </IfModule> <IfModule mod_headers.c> Header append Vary User-Agent env=!dont-vary </IfModule> </IfModule> SetOutputFilter DEFLATE <IfModule mod_setenvif.c> SetEnvIfNoCase Request_URI \.(?:rar|zip)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.(?:gif|jpg|png)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.(?:avi|mov|mp4)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary </IfModule> the line "Header unset Pragma FileETag None Header unset ETag" gave an internal server error in my case, but I am very happy with the result that it gave with the code above here. Thanks again! 5 Link to comment Share on other sites More sharing options...
Ayush Agarwal Posted March 12, 2014 Share Posted March 12, 2014 hi, My website link is lelobooks.com i have done almost all of the changes in the website but still my website my website is taking approx 5 + seconds to load. Please suggest me something. Thanks, Link to comment Share on other sites More sharing options...
HavanA Posted March 12, 2014 Share Posted March 12, 2014 hi, My website link is lelobooks.com i have done almost all of the changes in the website but still my website my website is taking approx 5 + seconds to load. Please suggest me something. Thanks, According to this report, there are still improvements to be made: http://gtmetrix.com/reports/www.lelobooks.com/2mpEbwr0 But even then, your page generation time is high. Which hosting do you use? Link to comment Share on other sites More sharing options...
Ayush Agarwal Posted March 13, 2014 Share Posted March 13, 2014 Hi, Thanks for your reply. i am using VPS shared hosting. Is there any website code issue or VPS server hosting issue? Link to comment Share on other sites More sharing options...
HavanA Posted March 13, 2014 Share Posted March 13, 2014 In my experience, optimalization is a long and ongoing process. I have my own topic here where I am struggeling with speed as well (although speed has much improved lately). There are several other topics on this forum about speed related issues that are unanswered. Maybe this forum is not even the place to be. Maybe some hosting-forum or so could provide better help. I can however advise you to start optimizing your images, of which some seem to be quite big. Start reducing the total size of your page. And installing Varnish, Nginx and APC on your VPS is in my opinion a must. And according to the size of your shop you should take the appropiate server resources as well (of which I still cannot exactly tell what is appropiate, but hosting a Prestashop with, lets say, 10.000 products in 3000 categories shouldn't be on a shared hosting). Happy selling! Link to comment Share on other sites More sharing options...
Ayush Agarwal Posted March 13, 2014 Share Posted March 13, 2014 Hi, Thanks for your valuable reply. So from your opinion i need to transfer my VPS server to a dedicated server. Is this will be the better option. So that i can get the 2 second speed. Link to comment Share on other sites More sharing options...
ricky11 Posted March 13, 2014 Share Posted March 13, 2014 Ayush, you will not get 2 second speed for full render for PS website not even locally. if you do please let me know. Link to comment Share on other sites More sharing options...
Alexgaw Posted May 27, 2014 Share Posted May 27, 2014 Hi, How do I set the expiration date for images I added already the mentioned code to my .htaccess but Google still complain about this: Leverage browser caching Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network. Cheers, /Alex Link to comment Share on other sites More sharing options...
myseo59 Posted July 25, 2014 Share Posted July 25, 2014 +1 for ALMAJ and Hardwell 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) Best regards. 1 Link to comment Share on other sites More sharing options...
thepan Posted August 2, 2014 Share Posted August 2, 2014 (edited) I tried this but it doesnt change anything still the same result on gtmetrix. I added these lines in my htaccess file Header unset Pragma FileETag None Header unset ETag <FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf|pdf|flv|mp3)$"> <IfModule mod_expires.c> ExpiresActive on ExpiresDefault "access plus 14 days" Header set Cache-Control "public" </IfModule> </FilesMatch> <FilesMatch "\.(html|htm|xml|txt|xsl)$"> Header set Cache-Control "max-age=7200, must-revalidate" </FilesMatch> but still get: The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources: http://xxx.com/img/logo.jpg (expiration not specified) http://xxx.com/modules/imageslider/views/img/1-slideImage_3.jpg (expiration not specified) http://xxx.com/themes/xxx/cache/v_0_0d00e8f914efc27bbda83b72453ba6e7.js (expiration not specified) http://xxx.com/themes/xxx/cache/v_0_9d318a19584dfc18ee2c0294695ad584_all.css (expiration not specified) http://connect.facebook.net/en_US/all.js (20 minutes) Edited August 2, 2014 by thepan (see edit history) Link to comment Share on other sites More sharing options...
jhd Posted September 6, 2014 Share Posted September 6, 2014 (edited) Hello, Do you know how to do it for Nginx? Or you know any post that talk about it? I have enabled Gzip in Nginx, but I do not know how to configure it with Prestashop. Best regards ## # Gzip Settings ## gzip on; gzip_disable "MSIE [1-6].(?!.*SV1)"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript $ Edited September 6, 2014 by jhd (see edit history) Link to comment Share on other sites More sharing options...
abhiz.2007 Posted October 22, 2014 Share Posted October 22, 2014 hello i am running abhishekproducts.in and on page insight i get eh following after trying the above code http://abhishekproducts.in/…v_21_fabd4c2f1733c0f44832f54b3d1530b5.js could save 151.5KiB (69% reduction). and the header for the same js shows this Response header for uncompresses JS Accept-Ranges: none Cache-Control: max-age=604800 Connection: keep-alive Content-Length: 278756 Content-Type: application/javascript Date: Wed, 22 Oct 2014 20:41:27 GMT Expires: Wed, 29 Oct 2014 20:41:27 GMT Last-Modified: Wed, 22 Oct 2014 19:49:25 GMT Server: nginx Vary: Accept-Encoding Where as the compress CSS shows this Cache-Control: max-age=604800 Connection: keep-alive Content-Encoding: gzip<------------------------------------look at this Content-Type: text/css Date: Wed, 22 Oct 2014 20:41:26 GMT Expires: Wed, 29 Oct 2014 20:41:26 GMT Last-Modified: Wed, 22 Oct 2014 19:49:22 GMT Server: nginx Transfer-Encoding: chunked Vary: Accept-Encoding Vary: Accept-Encoding so as you see the JS is not getting compresses where as the CSS and other html files are getting compresses. Any one any ideas on this ? Link to comment Share on other sites More sharing options...
trevorgilligan Posted January 30, 2015 Share Posted January 30, 2015 can someone let me know if this code is ok to put at bottom of htaccess file? thanks for the help @havana and @Spidersiteme <IfModule mod_mime.c> <filesmatch ".html.gz$"> ForceType text/html FileETag None </filesmatch> AddEncoding gzip .gz AddType text/html .gz AddType application/x-javascript .js AddType text/css .css </IfModule> <IfModule mod_deflate.c> SetEnvIfNoCase Request_URI .gz$ no-gzip AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/javascript <IfModule mod_setenvif.c> BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html </IfModule> <IfModule mod_headers.c> Header set Vary "Accept-Encoding, Cookie" Header set Cache-Control 'max-age=3600, must-revalidate' Header append Vary User-Agent env=!dont-vary </IfModule> </IfModule> <ifmodule mod_expires.c> ExpiresActive On ExpiresByType text/html A3600 </ifmodule> SetOutputFilter DEFLATE <IfModule mod_setenvif.c> SetEnvIfNoCase Request_URI \.(?:rar|zip)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.(?:gif|jpg|png)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.(?:avi|mov|mp4)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary </IfModule> also i assume the code i just posted goes under this? RewriteRule [0-9/]+/[0-9]+\.jpg$ - [F] # end ~ module watermark section Link to comment Share on other sites More sharing options...
trevorgilligan Posted February 13, 2015 Share Posted February 13, 2015 can i add this code: Header unset Cookie Header unset Set-Cookie <FilesMatch "!\.(gif|jpe?g|png)$"> php_value session.cookie_domain example.com </FilesMatch> would this speed up site? and would it effect the rest of the code? hav a nice weekend Link to comment Share on other sites More sharing options...
doekia Posted February 13, 2015 Share Posted February 13, 2015 No unless you are facing 15millions hit per seconds Please refrain for asking the exact same question on multiple topics. Link to comment Share on other sites More sharing options...
Dh42 Posted February 14, 2015 Share Posted February 14, 2015 That will not unset your google analytics cookie, so you will be serving the resource with a cookie. 1 Link to comment Share on other sites More sharing options...
Crowell Posted March 3, 2015 Share Posted March 3, 2015 I have added your first line to the .htaccess and " Internal Server ErrorThe server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log." I'm afraid to do the rest 1 Link to comment Share on other sites More sharing options...
trevorgilligan Posted April 14, 2015 Share Posted April 14, 2015 sorry @doekia didnt know i put up twice. again thank you for your help @dh42 and thanks also @crowell trev Link to comment Share on other sites More sharing options...
Ben90 Posted August 17, 2015 Share Posted August 17, 2015 Thanks Spidersiteme! My score went from 88% to 94% on pagespeed. I only added this at the bottom of the htaccess file: <IfModule mod_mime.c> AddType application/x-javascript .js AddType text/css .css </IfModule> <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/javascript <IfModule mod_setenvif.c> BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html </IfModule> <IfModule mod_headers.c> Header append Vary User-Agent env=!dont-vary </IfModule> </IfModule> SetOutputFilter DEFLATE <IfModule mod_setenvif.c> SetEnvIfNoCase Request_URI \.(?:rar|zip)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.(?:gif|jpg|png)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.(?:avi|mov|mp4)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary </IfModule> the line "Header unset Pragma FileETag None Header unset ETag" gave an internal server error in my case, but I am very happy with the result that it gave with the code above here. Thanks again! Wow! This code really works well! Just wondering why this thing not have been implemented in the first place Link to comment Share on other sites More sharing options...
Label L Posted September 28, 2015 Share Posted September 28, 2015 My site went from 48/100 on google page speed insights to 89~~~Thanks! 1 Link to comment Share on other sites More sharing options...
ultraseb Posted April 14, 2016 Share Posted April 14, 2016 Very very good ! my site 43/100 to 83/100 Thanks a lot for this code Link to comment Share on other sites More sharing options...
vivimax Posted May 4, 2016 Share Posted May 4, 2016 Thank you so much!!! :-) Vivi Link to comment Share on other sites More sharing options...
Shahraam Posted May 7, 2016 Share Posted May 7, 2016 Hi, I am trying to improve my site speed and then found this topic about how to speed up site and compression with htaccess file. Although the subject is old but it should help me to improve my site. However I didn't succeed to utilize the codes in htaccess file. Could anyone provide a fresh code for Prestashop 1.6 that I could add to my htaccess file? Thanks Link to comment Share on other sites More sharing options...
doekia Posted May 7, 2016 Share Posted May 7, 2016 Version 1.6+ does .htaccess optimisation off the shelf assuming you tick the apache optimisation option in SEO&URL and your hosting allows it Link to comment Share on other sites More sharing options...
kevinlanyi Posted August 29, 2016 Share Posted August 29, 2016 Can you look at my site also? Adjsuting CCC didnt helped too much still 15+ sec to load the site. www.10r.hu The system shows the siteURL.php and language.php loads too long. Also config, init, initheader, initcontent loads too long too. Any idea to fix these? Thanks a lot Link to comment Share on other sites More sharing options...
kevinlanyi Posted August 29, 2016 Share Posted August 29, 2016 Here are some screenshots of my Config info: http://imgur.com/a/KPIB5 Thanks a lot in advance! Link to comment Share on other sites More sharing options...
selectshop.at Posted November 10, 2017 Share Posted November 10, 2017 I'm closing this topic. It's very old and not for Prestashop versions over 1.5. Prestashop 1.6 ahs already all optimization included in header and also the use of latest php versions like 5.6. the optimizations should be done server sided. Link to comment Share on other sites More sharing options...
Recommended Posts