Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Speed Up and Optimise CS-Cart Version 3 Rate Topic   * * * * * 9 votes

 
  • StellarBytes
  • Senior Member
  • Members
  • Join Date: 08-Aug 11
  • 1807 posts

Posted 13 December 2012 - 09:20 PM #1

*
POPULAR

Here is a quick rundown of some simple yet very effective file changes to speed up your CS-Cart Version 3 stores.

Using these settings, I reduced my GTmetrix scores as follows:

Page Load Time: 21.09s > 4.6s
Total page size: 1.37MB > 585KB
Total number of requests: 99 > 85

UPDATE 30/01/13: htaccess optimisations and SmartOptimizer optimisations

First of all, very basic. Ensure your admin control panel has the 'Development Mode' link in the bottom-right corner. If the link says 'Live Mode', this means your store is running in Development Mode and vice versa.

In config.local.php:

$config['tweaks'] = array (
'js_compression' => true, // enables compession to reduce size of javascript files
'check_templates' => false, // disables templates checking to improve template engine speed
'inline_compilation' => true, // compiles nested templates in one file
'anti_csrf' => false, // protect forms from CSRF attacks
'disable_block_cache' => true, // used to disable block cache
'join_css' => true, // is used to unite css files into one file
'allow_php_in_templates' => false, // Allow to use {php} tags in templates
'disable_localizations' => true, // Disable Localizations functionality
'disable_google_base' => true, //Disable obsolete google base functionality
);

In store root .htaccess

DirectoryIndex index.html index.php
<IfModule mod_rewrite.c>
RewriteEngine on
# Pleas note that RewriteBase setting is obsolete use it only in case you experience  some problems with SEO addon.
# Some hostings require RewriteBase to be uncommented
# Example:
# Your store url is http://www.yourcompany.com/store/cart
# So "RewriteBase" should be:
# RewriteBase /store/cart
# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php?sef_rewrite=1 [L,QSA]
</IfModule>
<IfModule mod_expires.c>
		<FilesMatch "\.(ico|gif|jpg|jpeg|png|swf|css|js|html?|xml|txt)$">
				ExpiresActive On
				ExpiresDefault "access plus 10 years"
		</FilesMatch>
</IfModule>
<IfModule mod_headers.c>
<FilesMatch \.(css|js)$>
Header append Vary User-Agent
Header append Vary Accept-Encoding
Header append Cache-Control public
</FilesMatch>
<FilesMatch \.(bmp|png|gif|jpe?g|ico|flv|wmv|asf|asx|wma|wax|wmx|wm|swf|pdf|doc|rtf|xls|ppt|eot|ttf|otf|svg)$>
Header append Cache-Control public
</FilesMatch>
<FilesMatch \.(js|css|bmp|png|gif|jpe?g|ico|flv|wmv|asf|asx|wma|wax|wmx|wm|swf|pdf|doc|rtf|xls|ppt)$>
Header unset ETag
FileETag None
</FilesMatch>
</IfModule>

# Turn on Expires and set default to 0
<IfModule mod_expires.c>
ExpiresActive On
<FilesMatch \.css$>
ExpiresDefault "access plus 10 years"
</FilesMatch>
ExpiresByType text/css A315360000
<FilesMatch \.js$>
ExpiresDefault "access plus 10 years"
</FilesMatch>
ExpiresByType text/javascript A315360000
ExpiresByType application/javascript A315360000
ExpiresByType application/x-javascript A315360000
ExpiresByType text/x-js A315360000
ExpiresByType text/ecmascript A315360000
ExpiresByType application/ecmascript A315360000
ExpiresByType text/vbscript A315360000
ExpiresByType text/fluffscript A315360000
<FilesMatch \.(bmp|png|gif|jpe?g|ico)$>
ExpiresDefault "access plus 10 years"
</FilesMatch>
ExpiresByType image/gif A315360000
ExpiresByType image/png A315360000
ExpiresByType image/jpeg A315360000
ExpiresByType image/x-icon A315360000
ExpiresByType image/bmp A315360000
<FilesMatch \.(eot|ttf|otf|svg)$>
ExpiresDefault "access plus 10 years"
</FilesMatch>
ExpiresByType application/x-font-opentype A315360000
ExpiresByType application/x-font-truetype A315360000
ExpiresByType application/x-font-ttf A315360000
ExpiresByType application/x-font A315360000
ExpiresByType font/opentype A315360000
ExpiresByType font/otf A315360000
ExpiresByType application/vnd.oasis.opendocument.formula-template A315360000
ExpiresByType image/svg+xml A315360000
ExpiresByType application/vnd.ms-fontobject A315360000
ExpiresByType font/woff A315360000
<FilesMatch \.(flv|wmv|asf|asx|wma|wax|wmx|wm)$>
ExpiresDefault "access plus 10 years"
</FilesMatch>
ExpiresByType video/x-flv A315360000
ExpiresByType video/x-ms-wmv A315360000
ExpiresByType video/x-ms-asf A315360000
ExpiresByType video/x-ms-asx A315360000
ExpiresByType video/x-ms-wma A315360000
ExpiresByType video/x-ms-wax A315360000
ExpiresByType video/x-ms-wmx A315360000
ExpiresByType video/x-ms-wm A315360000
<FilesMatch \.(swf|pdf|doc|rtf|xls|ppt)$>
ExpiresDefault "access plus 10 years"
</FilesMatch>
ExpiresByType application/x-shockwave-flash A315360000
ExpiresByType application/pdf A315360000
</IfModule>
FileETag none
<IfModule mod_deflate.c>
<FilesMatch "\.(php|html)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>

Install a PHP Compression Engine:

Download and install SmartOptimizer, follow the instructions in the SmartOptimizer download file to install. Basically, upload the 'smartoptimizer' folder to the root of your hosting, and set the permissions of /smartoptimizer/cache/ to '777'. If you do decide to also use Smart Optimizer, add the following to the .htaccess file in the root of your store:
<IfModule !mod_expires.c>
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*\.(ico|gif|jpg|jpeg|png|swf|css|js|html?|xml|txt|pdf))$ smartoptimizer/?$1
</IfModule>
RewriteRule ^(.*\.(js|css))$ smartoptimizer/?$1

If you use any 'social' or Chat plugins, such as AddThis, ShareThis, LiveChat, Twitter, Facebook, etc, or an image banner scroller, which require JavaScript, I would advise you edit your relevent template files and add the 'defer async' tag on the <script src> tag for JavaScript, like so:

<script type="text/javascript" defer async src="js/easySlider1.7.js"></script>

Note: These steps are for an Apache server. Suitable for CS-Cart Version 3. May work on previous versions of the cart but config.local.php does differ slightly in version 2.

There are various other elements you could change to speed up your site, but most of these other changes are on a site-specific basis.

I achieved the speed increase as previously mentioned with only these changes, with various further changes, I reduced the page load time to under 3 seconds, with a file size of 450kb and 78 requests. These simple steps will hopefully help speed up your site too.

If you have any other tips or suggestions, please feel free to contribute to this thread.
Hire StellarBytes for CS-Cart Design & Development Services

 
  • Onkel_Sid
  • Junior Member
  • Members
  • Join Date: 04-Sep 10
  • 301 posts

Posted 13 December 2012 - 10:00 PM #2

Great tips.

For people like myself - that are not so used to messing with the .htaccess-file i see that GTmetrix recomends this site:

https://www.tweaky.com/gt

They do much of the stuff you are listing in your post for $39.

Stop smoking start vaping: Dampskyen.no


 
  • StellarBytes
  • Senior Member
  • Members
  • Join Date: 08-Aug 11
  • 1807 posts

Posted 13 December 2012 - 11:31 PM #3

The .htaccess part is easy. Download it from your server, edit it in Notepad (or similar text editor), replace the default content with all as above, save as .htaccess and re-upload to the root of your hosting.

Not sure on the Tweaky thing, as I would suspect it could get quite expensive, but you never know.
Hire StellarBytes for CS-Cart Design & Development Services

 
  • vidan
  • Senior Member
  • Members
  • Join Date: 11-Jan 10
  • 373 posts

Posted 15 December 2012 - 11:52 AM #4

great post, can anyone with decent skills of nginx convert the htaccess thx

 
  • gabbo
  • Junior Member
  • Trial users
  • Join Date: 04-May 11
  • 92 posts

Posted 16 December 2012 - 06:58 AM #5

Anyone who can describe how to setup php/mysql/nginx and how to configure it for cscart ?

 
  • StellarBytes
  • Senior Member
  • Members
  • Join Date: 08-Aug 11
  • 1807 posts

Posted 16 December 2012 - 05:23 PM #6

I'm sure I read a thread by BaDTaG who is currently setting up CS-Cart to run on nginx.
Hire StellarBytes for CS-Cart Design & Development Services

 
  • miracles
  • Senior Member
  • Members
  • Join Date: 19-Sep 07
  • 1533 posts

Posted 17 December 2012 - 06:36 PM #7

How is your current score in google and yslow ?
CS-CART 3.0.6 GRENADE

Please vote for CDN Add-on

For SEO Article Submission, Forum Profile Links, Web 2.0 links, contact me through PM.

 
  • StellarBytes
  • Senior Member
  • Members
  • Join Date: 08-Aug 11
  • 1807 posts

Posted 17 December 2012 - 07:18 PM #8

For the current site I am working on...

Before any optimisation:

Pagespeed: F
YSlow: E

After implementing changes as above:

Pagespeed: C
YSlow: C

Further simple optimisation with much more to come:

Pagespeed: B
YSlow: B
Hire StellarBytes for CS-Cart Design & Development Services

 
  • ehenderichs
  • Advanced Member
  • Members
  • Join Date: 08-Oct 12
  • 104 posts

Posted 18 December 2012 - 12:29 AM #9

Great work. The tweaks in the config_local gained a few performance points on Pagespeed (from 88 to 89) and YSlow (79 to 83). Still my site feels slughish.

Looking forward to your progress in optimizing the perfomance of your site.
The first cs-cart project for our new dutch company Sooned was a dutch erotic webshop called eely.nl.

 
  • miracles
  • Senior Member
  • Members
  • Join Date: 19-Sep 07
  • 1533 posts

Posted 18 December 2012 - 05:54 AM #10

I have done some tweak which is written by OP and installed Varnish in my VPS so now i am getting:

Google - 93 A Grade from 85 B Grade
Yahoo - 83 B Grade from 75 C Grade

I am not using CDN but if you need CDN you can either go with CDN77.com, Stylexnetworks.com or MaxCDN.com all have in low budget
CS-CART 3.0.6 GRENADE

Please vote for CDN Add-on

For SEO Article Submission, Forum Profile Links, Web 2.0 links, contact me through PM.

 
  • CutRiteFX
  • Senior Member
  • Members
  • Join Date: 02-Jun 08
  • 431 posts

Posted 07 January 2013 - 11:27 PM #11

Ours was a C and C just changed the config.local and .htaccess shown above and Uninstalled disabled add-ons and now at
Page Speed Grade:
B
(87%)
78%

B
YSlow Grade:
(81%)
76%

We are also on a shared server.

CS-Cart 4.7.4


 
  • Jayhawk
  • Junior Member
  • Members
  • Join Date: 17-Feb 11
  • 80 posts

Posted 10 January 2013 - 08:59 AM #12

I replaced the htaccess with this one and I received a server error.

Did I do something wrong or something may be messing it up?


Here is a quick rundown of some simple yet very effective file changes to speed up your CS-Cart Version 3 stores.

Using these settings, I reduced my GTmetrix scores as follows:

Page Load Time: 21.09s > 4.6KB
Total page size: 1.37MB > 585KB
Total number of requests: 99 > 85

First of all, very basic. Ensure your admin control panel has the 'Development Mode' link in the bottom-right corner. If the link says 'Live Mode', this means your store is running in Development Mode and vice versa.

In config.local.php:

$config['tweaks'] = array (
'js_compression' => true, // enables compession to reduce size of javascript files
'check_templates' => false, // disables templates checking to improve template engine speed
'inline_compilation' => true, // compiles nested templates in one file
'anti_csrf' => false, // protect forms from CSRF attacks
'disable_block_cache' => true, // used to disable block cache
'join_css' => true, // is used to unite css files into one file
'allow_php_in_templates' => false, // Allow to use {php} tags in templates
'disable_localizations' => true, // Disable Localizations functionality
'disable_google_base' => true, //Disable obsolete google base functionality
);

In store root .htaccess

DirectoryIndex index.html index.php
<IfModule mod_rewrite.c>
RewriteEngine on
# Pleas note that RewriteBase setting is obsolete use it only in case you experience  some problems with SEO addon.
# Some hostings require RewriteBase to be uncommented
# Example:
# Your store url is http://www.yourcompany.com/store/cart
# So "RewriteBase" should be:
# RewriteBase /store/cart
# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php?sef_rewrite=1 [L,QSA]
</IfModule>
<IfModule mod_expires.c>
		<FilesMatch "\.(ico|gif|jpg|jpeg|png|swf|css|js|html?|xml|txt)$">
				ExpiresActive On
				ExpiresDefault "access plus 10 years"
		</FilesMatch>
</IfModule>
<IfModule mod_headers.c>
<FilesMatch \.(css|js)$>
Header append Vary User-Agent
Header append Vary Accept-Encoding
Header append Cache-Control public
</FilesMatch>
<FilesMatch \.(bmp|png|gif|jpe?g|ico|flv|wmv|asf|asx|wma|wax|wmx|wm|swf|pdf|doc|rtf|xls|ppt|eot|ttf|otf|svg)$>
Header append Cache-Control public
</FilesMatch>
<FilesMatch \.(js|css|bmp|png|gif|jpe?g|ico|flv|wmv|asf|asx|wma|wax|wmx|wm|swf|pdf|doc|rtf|xls|ppt)$>
Header unset ETag
FileETag None
</FilesMatch>
</IfModule>

# Turn on Expires and set default to 0
<IfModule mod_expires.c>
ExpiresActive On
<FilesMatch \.css$>
ExpiresDefault "access plus 10 years"
</FilesMatch>
ExpiresByType text/css A315360000
<FilesMatch \.js$>
ExpiresDefault "access plus 10 years"
</FilesMatch>
ExpiresByType text/javascript A315360000
ExpiresByType application/javascript A315360000
ExpiresByType application/x-javascript A315360000
ExpiresByType text/x-js A315360000
ExpiresByType text/ecmascript A315360000
ExpiresByType application/ecmascript A315360000
ExpiresByType text/vbscript A315360000
ExpiresByType text/fluffscript A315360000
<FilesMatch \.(bmp|png|gif|jpe?g|ico)$>
ExpiresDefault "access plus 10 years"
</FilesMatch>
ExpiresByType image/gif A315360000
ExpiresByType image/png A315360000
ExpiresByType image/jpeg A315360000
ExpiresByType image/x-icon A315360000
ExpiresByType image/bmp A315360000
<FilesMatch \.(eot|ttf|otf|svg)$>
ExpiresDefault "access plus 10 years"
</FilesMatch>
ExpiresByType application/x-font-opentype A315360000
ExpiresByType application/x-font-truetype A315360000
ExpiresByType application/x-font-ttf A315360000
ExpiresByType application/x-font A315360000
ExpiresByType font/opentype A315360000
ExpiresByType font/otf A315360000
ExpiresByType application/vnd.oasis.opendocument.formula-template A315360000
ExpiresByType image/svg+xml A315360000
ExpiresByType application/vnd.ms-fontobject A315360000
ExpiresByType font/woff A315360000
<FilesMatch \.(flv|wmv|asf|asx|wma|wax|wmx|wm)$>
ExpiresDefault "access plus 10 years"
</FilesMatch>
ExpiresByType video/x-flv A315360000
ExpiresByType video/x-ms-wmv A315360000
ExpiresByType video/x-ms-asf A315360000
ExpiresByType video/x-ms-asx A315360000
ExpiresByType video/x-ms-wma A315360000
ExpiresByType video/x-ms-wax A315360000
ExpiresByType video/x-ms-wmx A315360000
ExpiresByType video/x-ms-wm A315360000
<FilesMatch \.(swf|pdf|doc|rtf|xls|ppt)$>
ExpiresDefault "access plus 10 years"
</FilesMatch>
ExpiresByType application/x-shockwave-flash A315360000
ExpiresByType application/pdf A315360000
</IfModule>
FileETag none
<IfModule mod_deflate.c>
<FilesMatch "\.(php|html)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>

Install a PHP Compression Engine:

Download and install SmartOptimizer, follow the instructions in the SmartOptimizer download file to install. Basically, upload the 'smartoptimizer' folder to the root of your hosting, and set the permissions of /smartoptimizer/cache/ to '777'. If you do decide to also use Smart Optimizer, add the following to the .htaccess file in the root of your store:
<IfModule !mod_expires.c>
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*\.(ico|gif|jpg|jpeg|png|swf|css|js|html?|xml|txt|pdf))$ smartoptimizer/?$1
</IfModule>
RewriteRule ^(.*\.(js|css))$ smartoptimizer/?$1

If you use any 'social' or Chat plugins, such as AddThis, ShareThis, LiveChat, Twitter, Facebook, etc, or an image banner scroller, which require JavaScript, I would advise you edit your relevent template files and add the 'defer async' tag on the <script src> tag for JavaScript, like so:

<script type="text/javascript" defer async src="js/easySlider1.7.js"></script>

Note: These steps are for an Apache server. Suitable for CS-Cart Version 3. May work on previous versions of the cart but config.local.php does differ slightly in version 2.

There are various other elements you could change to speed up your site, but most of these other changes are on a site-specific basis.

I achieved the speed increase as previously mentioned with only these changes, with various further changes, I reduced the page load time to under 3 seconds, with a file size of 450kb and 78 requests. These simple steps will hopefully help speed up your site too.

If you have any other tips or suggestions, please feel free to contribute to this thread.



 
  • StellarBytes
  • Senior Member
  • Members
  • Join Date: 08-Aug 11
  • 1807 posts

Posted 10 January 2013 - 12:15 PM #13

I replaced the htaccess with this one and I received a server error.

Did I do something wrong or something may be messing it up?

What error? Which version of Apache? Is mod_rewrite enabled on your server? What other rules do you have in your .htaccess, if any?
Hire StellarBytes for CS-Cart Design & Development Services

 
  • Adrian8
  • Junior Member
  • Members
  • Join Date: 04-Feb 11
  • 138 posts

Posted 10 January 2013 - 03:17 PM #14

Hi StellarBytes,

What is your page load time for CS-Cart Version 3, 21 seconds seems very high?

SmartOptimizer is almost redundant with CS-Cart version 3 as it already combines css and js files. Though CS-cart should add minify (the code for which is probably quite easy to integrate) to the combined files which would improve things. Using SmartOptimizer is just another layer of unnecessary software (especially with CS-Cart version 3) using vital server resource.

It is possible to use NGinx + FPM-PHP + XCache + MySQL which will improve performance and reduce server load, but it is not a simple task to setup.
www.ecopolar.com - V2.1.4
www.ledpolar.com - V2.2.4

 
  • Jayhawk
  • Junior Member
  • Members
  • Join Date: 17-Feb 11
  • 80 posts

Posted 10 January 2013 - 03:32 PM #15

What error? Which version of Apache? Is mod_rewrite enabled on your server? What other rules do you have in your .htaccess, if any?


Apache Version 2 with mod_rewrite enabled.

Here is what is in my htaccess. I have not done anything to it since it was installed.

I simply replaced mine with the your information.


DirectoryIndex index.html index.php

<IfModule mod_rewrite.c>
RewriteEngine on
# Some hostings require RewriteBase to be uncommented
# Example:
# Your store url is http://www.yourcompany.com/store/cart
# So "RewriteBase" should be:
# RewriteBase /store/cart
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !\.(png|gif|ico|swf|jpe?g|js|css)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php?sef_rewrite=1 [L,QSA]

</IfModule>

 
  • StellarBytes
  • Senior Member
  • Members
  • Join Date: 08-Aug 11
  • 1807 posts

Posted 10 January 2013 - 08:35 PM #16

Try this. Uncomment the RewriteBase line, like so:

Replace:
# RewriteBase /
With:
RewriteBase /

Hire StellarBytes for CS-Cart Design & Development Services

 
  • dsc81
  • Advanced Member
  • Members
  • Join Date: 14-Sep 11
  • 100 posts

Posted 11 January 2013 - 04:08 AM #17

Hi Stellar,
How about if I using cs-cart 2.2.5 and i using apache 2.x
which file should I change?
Thanks

 
  • StellarBytes
  • Senior Member
  • Members
  • Join Date: 08-Aug 11
  • 1807 posts

Posted 11 January 2013 - 04:31 PM #18

Hi Stellar,
How about if I using cs-cart 2.2.5 and i using apache 2.x
which file should I change?
Thanks

I also use the same .htaccess and SmartOptimizer with v2 stores.
Hire StellarBytes for CS-Cart Design & Development Services

 
  • Jayhawk
  • Junior Member
  • Members
  • Join Date: 17-Feb 11
  • 80 posts

Posted 11 January 2013 - 05:05 PM #19

Try this. Uncomment the RewriteBase line, like so: Replace:

# RewriteBase /
With:
RewriteBase /


That did not change anything

 
  • StellarBytes
  • Senior Member
  • Members
  • Join Date: 08-Aug 11
  • 1807 posts

Posted 11 January 2013 - 05:57 PM #20

What is your page load time for CS-Cart Version 3, 21 seconds seems very high?

Page Load Time was around 20 seconds, implementing this .htaccess decreased to just under 7 seconds, adding SmartOptimizer brings it down to 3.2 seconds.

SmartOptimizer is almost redundant with CS-Cart version 3 as it already combines css and js files. Though CS-cart should add minify (the code for which is probably quite easy to integrate) to the combined files which would improve things. Using SmartOptimizer is just another layer of unnecessary software (especially with CS-Cart version 3) using vital server resource.

It is possible to use NGinx + FPM-PHP + XCache + MySQL which will improve performance and reduce server load, but it is not a simple task to setup.

True, but I have only seen lower page load times and lower page size with SmartOptimizer on v3 sites, not any adverse effects.

NGinx would be great, but isn't really a "follow the clicky path" type installation like this is, so is ruled out for the majority of CS-Cart users.

I just posted this as it has greatly helped all my V2 and V3 sites on different Apache server setups.
Hire StellarBytes for CS-Cart Design & Development Services