SmartOptimizer with CS-Cart optimization

Read Time:4 Minute, 7 Second

Reference: http://forum.cs-cart.com/topic/29499-speed-up-and-optimise-cs-cart-version-3/

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

 

 

Reference: http://farhadi.ir/projects/smartoptimizer/

SmartOptimizer

SmartOptimizer is an out of the box PHP utility to improve your website performance using techniques such as minification and gzip compression.

How does it work?

It optimizes your website performance by minifying and compressing scripts and styles of your website. In order to do that, all of the requests to css and javascript files in your website need to be redirected and processed by SmartOptimizer. The included .htaccess file will do that for you if you’re using an Apache web server.

SmartOptimizer stores compressed and minified files in a cache folder. So it doesn’t need to repeat the process for further requests.

Where should I use it?

If your website has a lot of scripts and styles, and YSlow or Page Speed shows a low grade for it, then using SmartOptimizer might be useful to improve its performance.

Where should I avoid it?

Well, actually SmartOptimizer improves the front-end of your website not the back-end. In the back-end SmartOptimizer slightly increases cpu and memory usages. So it might cause problems for your server if you have a popular website with lots of visitors.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.