Optimizing Cs-Cart For Better Performance

Hi



I recently did a performance comparison test of our store on GTMetrix.com. The results were nothing to write home about. My CS-Cart installation is even though on a dedicated VPS with 2Gig of memory and the other resources to match it is not faster but rather slower than that of my competitors and even slower than some of the cs-cart powered website of developers here in the CS-Cart community.



If a developer can assist please sent me a pm.



[attachment=8577:performance_screenshot.JPG]

performance_screenshot.JPG

Members of the CS-Cart community,

This is a follow up on my question. There is an article in the Knowledge Base - called “Increasing Site Performance” and I have question that is related to the procedure of optimizing the database and amending the code in the config.local.php file.



Q: is this best done when you just about to go live but you may still want to install some future add-ons or add new products. In other words can you do this at any time in the process? I am just about to go live with our store.



Kind regards.

I have yet to see any performance numbers that indicate that caching in the database (note you are caching DB queries in the same DB as you are fetching them from) is any faster than the file method. If you have detailed statistics on this, please publish.



What caching method is used can be done at any time. As with all caching systems, the first access will be the slowest while the cache is built.

[quote name='tbirnseth' timestamp='1414438728' post='195384']

I have yet to see any performance numbers that indicate that caching in the database (note you are caching DB queries in the same DB as you are fetching them from) is any faster than the file method. If you have detailed statistics on this, please publish.



What caching method is used can be done at any time. As with all caching systems, the first access will be the slowest while the cache is built.

[/quote]



Well I have yet to optimize the database as I have written the first post. Simbirsk Technologies Ltd write in there knowledge base that you need to optimize the database first and then replace the caching from 'file' to 'mysql'.



But the way you write about it Tony, it does not matter at all ? Are there perhaps other better methods of increasing loading times of my current live setup ?

I do not have any suggestions other than to have the appropriate server for the size of your site and the visitor count you expect. Personally, I"m about “keep it simple”. It does not make logical sense to me to cache data in the same database that you are trying to avoid accessing. Separate DB, maybe, but it should be served by a completely sepaate instance of mySQL (or preferably a different DB server entirely if it's going to reside on the same server)… As far as all the optimizers go, until there is true page caching, I think you're picking at zits.

[quote name='tbirnseth' timestamp='1414513754' post='195512']

As far as all the optimizers go, until there is true page caching, I think you're picking at zits.

[/quote]



How damaging would it be in your opinion then to optimize the database as you can do within the backend administration of CS-Cart ?

I'm not understanding your question. The DB is pretty well optimized though the queries are many times less than optimal because they need to account for addons and other adjustments to them.

Out of the box, CS-Cart doesn't include any Cache Control in the .htaccess file.

Just looking at the screen shot you posted I can see that you could dramatically increase your GTMetrix score by addressing the items they list under Recommendations. Several are easy to fix.

  1. Leverage Browser Caching: Important for your traffic's browsing experience. Your customers fetch your graphics, JS, CSS and HTML ONCE and cache it.
  2. Specify a Vary: Accept-Encoding header: I thought this was enabled by default in the original .htaccess file.
  3. Enable gzip compression: the single greatest accelerator you are going to implement.



    This a complete copy of my .htaccess file for v4 running on a LAMP server. It completely replaces the one provided with the cart. It fixes the three items I listed above. And also implements mod_deflate.:


DirectoryIndex index.html index.php

Header append Vary: Accept-Encoding
Header set X-Content-Type-Options "nosniff"

order allow,deny
deny from all

FileETag None

Header set Access-Control-Allow-Origin "*"


Header unset ETag
ExpiresActive on
ExpiresDefault "access plus 1 month"
#CSS
ExpiresByType text/css "access plus 1 year"
#Data interchange
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType application/ld+json "access plus 0 seconds"
ExpiresByType application/vnd.geo+json "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType text/xml "access plus 0 seconds"
#Favicon (cannot be renamed!) and cursor images
ExpiresByType image/x-icon "access plus 1 year"
#HTML components (HTCs)
ExpiresByType text/x-component "access plus 1 month"
#HTML
ExpiresByType text/html "access plus 1 month"
#JavaScript
ExpiresByType application/javascript "access plus 1 year"
#Manifest files
ExpiresByType application/manifest+json "access plus 1 year"
ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
ExpiresByType text/cache-manifest "access plus 0 seconds"
#Media
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
#Web feeds
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
#Web fonts
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/font-woff2 "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
#CSS w/gzip

ExpiresDefault "access plus 1 year"
ForceType text/css
Header set Content-Encoding: gzip
Header set Cache-control: private

#JavaScript w/gzip

ExpiresDefault "access plus 1 year"
ForceType text/javascript
Header set Content-Encoding: gzip
Header set Cache-control: private




AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml


RewriteEngine on
Options -MultiViews
#Redirects go here
#RewriteCond %{REQUEST_URI} .*\/SEO_URL\.html
#RewriteRule ^.*$ http://www.domainname.com/NEW_SEO_URL.html [L,R=301]
AddEncoding gzip .gz
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} \.(js|css)$
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [QSA,L]
RewriteCond %{REQUEST_URI} ^api/(.*)$ [or]
RewriteCond %{REQUEST_URI} .*/api/(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*api/(.*)$ api.php?_d=$1&ajax_custom=1 [L,QSA]
RewriteCond %{REQUEST_URI} \.(png|gif|ico|swf|jpe?g|js|css|ttf|svg|eot|woff|yml|xml)$ [or]
RewriteCond %{REQUEST_URI} store_closed.html$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*?)\/(.*)$ $2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L,QSA]






As a Webmaster you should be familiar with Cache Control, gzip and .htaccess files. This is not “Developer” level optimization.

You should also make certain that gzip is enabled on your server.

Don, thanks for sharing this. My site went from:

E-53% and C-74%

to

D-63% and B-82%



Just from using your htaccess file!

For gtmetrix that's not bad at all, as we are hosted in Australia on Australian Servers, the site is always slower when running international tests. I'm really surprised that it made so much of a difference from the standard cs-cart one, so I just had to jump on to say thanks!

Don I tried your file and it did some good but I guess on my site and server more has to be done to get anywhere below D. But still many thanks for sharing your file.

[attachment=8624:gtmetrix_afterchangehtaccesfile.JPG]

gtmetrix_afterchangehtaccesfile.JPG

As for gzip compression being abled… it has been before I posted this thread.[attachment=8625:gzip_enabled.JPG]

gzip_enabled.JPG

If gzip module is running, is it being used?

If you have cPanel, log into your cPanel account and click Optimize Website under Software/Services. Choose “Compress all content” and update settings.

According to your GTMetrix score, gzip is not being used for all content - probably just for the .css.gz and .js.gz files included with CS-Cart.



Also, there are several websites that offer js Minifiers. All you have to do is to paste the contents of an existing js file into the Minifier, run the process, copy the output and paste it over your current file's contents. I do directly on the server so my local copy is a backup of the original. I had a few scripts that didn't function correctly after minification: tabs.js, and another, so I just uploaded the original and moved on.

[quote name='bytraper' timestamp='1415029429' post='195956']

Don, thanks for sharing this. My site went from:

E-53% and C-74%

to

D-63% and B-82%



Just from using your htaccess file!

For gtmetrix that's not bad at all, as we are hosted in Australia on Australian Servers, the site is always slower when running international tests. I'm really surprised that it made so much of a difference from the standard cs-cart one, so I just had to jump on to say thanks!

[/quote]



Your welcome.

[quote name='Magpie Don' timestamp='1415048965' post='195972']

If gzip module is running, is it being used?

If you have cPanel, log into your cPanel account and click Optimize Website under Software/Services. Choose “Compress all content” and update settings.

According to your GTMetrix score, gzip is not being used for all content - probably just for the .css.gz and .js.gz files included with CS-Cart.



Also, there are several websites that offer js Minifiers. All you have to do is to paste the contents of an existing js file into the Minifier, run the process, copy the output and paste it over your current file's contents. I do directly on the server so my local copy is a backup of the original. I had a few scripts that didn't function correctly after minification: tabs.js, and another, so I just uploaded the original and moved on.

[/quote]



Don,



I did a follow up at first with figuring out how to really enable compression and I found this code below on the site of GTmetrix.com -

[url=“Enable compression | GTmetrix”]http://gtmetrix.com/...ompression.html[/url]


```php


Compress HTML, CSS, JavaScript, Text, XML and fonts

AddOutputFilterByType DEFLATE application/javascript

AddOutputFilterByType DEFLATE application/rss+xml

AddOutputFilterByType DEFLATE application/vnd.ms-fontobject

AddOutputFilterByType DEFLATE application/x-font

AddOutputFilterByType DEFLATE application/x-font-opentype

AddOutputFilterByType DEFLATE application/x-font-otf

AddOutputFilterByType DEFLATE application/x-font-truetype

AddOutputFilterByType DEFLATE application/x-font-ttf

AddOutputFilterByType DEFLATE application/x-javascript

AddOutputFilterByType DEFLATE application/xhtml+xml

AddOutputFilterByType DEFLATE application/xml

AddOutputFilterByType DEFLATE font/opentype

AddOutputFilterByType DEFLATE font/otf

AddOutputFilterByType DEFLATE font/ttf

AddOutputFilterByType DEFLATE image/svg+xml

AddOutputFilterByType DEFLATE image/x-icon

AddOutputFilterByType DEFLATE text/css

AddOutputFilterByType DEFLATE text/html

AddOutputFilterByType DEFLATE text/javascript

AddOutputFilterByType DEFLATE text/plain

AddOutputFilterByType DEFLATE text/xml

Remove browser bugs (only needed for really old browsers)

BrowserMatch ^Mozilla/4 gzip-only-text/html

BrowserMatch ^Mozilla/4.0[678] no-gzip

BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

Header append Vary User-Agent



```



I added that code to the new .htaccess file that you posted here in this thread.



The results now are already so much better





[attachment=8626:afteramending_htaccessfile2.JPG]

afteramending_htaccessfile2.JPG

[quote name='Magpie Don' timestamp='1415048965' post='195972']

If gzip module is running, is it being used?

[/quote]

Now it is used, yes as you can see by the results above. Thanks for asking.


[quote name='Magpie Don' timestamp='1415048965' post='195972']

If you have cPanel, log into your cPanel account and click Optimize Website under Software/Services. Choose “Compress all content” and update settings.

According to your GTMetrix score, gzip is not being used for all content - probably just for the .css.gz and .js.gz files included with CS-Cart.

[/quote]

I finished that last part just now - see also the new results below


[quote name='Magpie Don' timestamp='1415048965' post='195972']

Also, there are several websites that offer js Minifiers. All you have to do is to paste the contents of an existing js file into the Minifier, run the process, copy the output and paste it over your current file's contents. I do directly on the server so my local copy is a backup of the original. I had a few scripts that didn't function correctly after minification: tabs.js, and another, so I just uploaded the original and moved on.

[/quote]



I may have to pass on that, that is currently a bit beyond my comrpehension. That is to say I pass for now, the time being. Lot's of work still to do now on part of the SSL issue I posted elsewhere on this forum.



Still many thanks Don and thanks to the Internet for making it so easy to find the things you need to know.



PS I also added some code in the .htaccess file





ExpiresActive on
ExpiresDefault "access plus 2 days"


Make sure to check your sitemap generates correctly after making your changes.



John

[quote name='johnbol1' timestamp='1415092998' post='195997']

Make sure to check your sitemap generates correctly after making your changes.



John

[/quote]



I did John but thanks for asking/ reminding. Sitemap is working fine at the moment.



Anthony

here my numbers in gtmetrix:







If you have any question about my files and configuration just let me know.



8)

[quote name=‘Rafass’ timestamp=‘1415813649’ post=‘196797’]

here my numbers in gtmetrix:







If you have some question about my files and configuration just let me know.



8)

[/quote]



All I can say is your page must not have very much on it. 6 requests.

[quote name=‘kingsleypress’ timestamp=‘1415813843’ post=‘196799’]

All I can say is your page must not have very much on it. 6 requests.

[/quote]



Is beta yet. I’m testing and learning.

anyway is already installed everything I need.

I want to achieve the best speed and optimisation first 8)

.