Speed Up and Optimise CS-Cart Version 3

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



[color=#006400]UPDATE 30/01/13: [/color][color=#006400]htaccess optimisations and SmartOptimizer optimisations[/color]



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


```php

DirectoryIndex index.html index.php



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]







ExpiresActive On

ExpiresDefault “access plus 10 years”









Header append Vary User-Agent

Header append Vary Accept-Encoding

Header append Cache-Control public





Header append Cache-Control public





Header unset ETag

FileETag None






Turn on Expires and set default to 0



ExpiresActive On



ExpiresDefault “access plus 10 years”



ExpiresByType text/css A315360000



ExpiresDefault “access plus 10 years”



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



ExpiresDefault “access plus 10 years”



ExpiresByType image/gif A315360000

ExpiresByType image/png A315360000

ExpiresByType image/jpeg A315360000

ExpiresByType image/x-icon A315360000

ExpiresByType image/bmp A315360000



ExpiresDefault “access plus 10 years”



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



ExpiresDefault “access plus 10 years”



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



ExpiresDefault “access plus 10 years”



ExpiresByType application/x-shockwave-flash A315360000

ExpiresByType application/pdf A315360000



FileETag none





SetOutputFilter DEFLATE





```



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:


RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*\.(ico|gif|jpg|jpeg|png|swf|css|js|html?|xml|txt|pdf))$ smartoptimizer/?$1

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

```



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.

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.

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.

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

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

I'm sure I read a thread by BaDTaG who is currently setting up CS-Cart to run on nginx.

How is your current score in google and yslow ?

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

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.

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

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.

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?




[quote name='StellarBytes' timestamp='1355433621' post='151110']

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


```php

DirectoryIndex index.html index.php



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]







ExpiresActive On

ExpiresDefault “access plus 10 years”









Header append Vary User-Agent

Header append Vary Accept-Encoding

Header append Cache-Control public





Header append Cache-Control public





Header unset ETag

FileETag None






Turn on Expires and set default to 0



ExpiresActive On



ExpiresDefault “access plus 10 years”



ExpiresByType text/css A315360000



ExpiresDefault “access plus 10 years”



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



ExpiresDefault “access plus 10 years”



ExpiresByType image/gif A315360000

ExpiresByType image/png A315360000

ExpiresByType image/jpeg A315360000

ExpiresByType image/x-icon A315360000

ExpiresByType image/bmp A315360000



ExpiresDefault “access plus 10 years”



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



ExpiresDefault “access plus 10 years”



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



ExpiresDefault “access plus 10 years”



ExpiresByType application/x-shockwave-flash A315360000

ExpiresByType application/pdf A315360000



FileETag none





SetOutputFilter DEFLATE





```



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:


RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*\.(ico|gif|jpg|jpeg|png|swf|css|js|html?|xml|txt|pdf))$ smartoptimizer/?$1

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

```



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.

[/quote]

[quote name='Jayhawk' timestamp='1357808355' post='152569']

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?

[/quote]

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

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.

[quote name='StellarBytes' timestamp='1357820137' post='152583']

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

[/quote]



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





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]



Try this. Uncomment the RewriteBase line, like so:



Replace:

```php

RewriteBase /

```

With:


RewriteBase /

Hi Stellar,

How about if I using cs-cart 2.2.5 and i using apache 2.x

which file should I change?

Thanks

[quote name='dsc81' timestamp='1357877309' post='152623']

Hi Stellar,

How about if I using cs-cart 2.2.5 and i using apache 2.x

which file should I change?

Thanks

[/quote]

I also use the same .htaccess and SmartOptimizer with v2 stores.

[quote name='StellarBytes' timestamp='1357850155' post='152612'] Try this. Uncomment the RewriteBase line, like so: Replace: # RewriteBase / With: RewriteBase / [/quote]



That did not change anything

[quote name='Adrian8' timestamp='1357831066' post='152590']

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

[/quote]

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.

[quote name='Adrian8' timestamp='1357831066' post='152590']

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.

[/quote]

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.