Jump to content

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

Speed Up Your CS-Cart eCommerce Website - .htaccess - Step 5 Rate Topic   - - - - -

 
  • Lee Li Pop
  • Senior Member
  • Members
  • Join Date: 07-Mar 08
  • 941 posts

Posted 17 November 2010 - 06:48 PM #1

Hello All,

Quick reminder:

The most important step is Gzip as shown in Step 1
The second important step is SmartOptimizer as explained in Step 2
And now, the most difficult to build and test, is the .htaccess.

I bypass minor steps such as Step 4 with so few followers. In fact, I understand you: This Step 4 is too difficult.

So, this step 5 is a "Copy and Paste" code. I can't do easier!

So, I shortcut my promise to delay the publishing of this third most important step to boost your CS-Cart website.

Why publish it now?

The Christmas season will soon beginning, so, it's now time to have a full power CS-Cart website.

Remember, I worked and tested for 22 hours non-stop to find this (nearly perfect for me) ".htaccess". With this .htaccess added to Steps 1 & 2, your website would go up to Yslow! result to ~88, and a PageSpeed result to ~85.

In practice, to get the 2 to 5 last points to get Grade A are hidden in minors steps. However, I will NOT give you, because, they are too difficult to acquire, and are time consuming.
Therefore, I wish you a merry Christmas! Posted Image

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/cscart
# So "RewriteBase" should be:
# RewriteBase /store/cscart 
# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php?sef_rewrite=1 [L,QSA]
RewriteRule ^(.*\.(js|css))$ smartoptimizer/?$1
</IfModule>	
	
	<IfModule !mod_expires.c>
		RewriteCond %{REQUEST_FILENAME} -f
		RewriteRule ^(.*\.(ico|gif|jpg|jpeg|png|swf|css|js|html?|xml|txt))$ smartoptimizer/?$1
	</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 private
 </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
 ExpiresByType application/msword A315360000
 ExpiresByType application/rtf A315360000
 ExpiresByType application/vnd.ms-excel A315360000
 ExpiresByType application/vnd.ms-powerpoint A315360000
</IfModule>
FileETag none
<IfModule mod_deflate.c>
<FilesMatch "\.(php|html)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>

Please, Nota Bene:

1 - This is NOT my full .htaccess (the missing code is security related, and powerful SEO rules. Sorry, this missing part will be NEVER reveled)

2 - I do NOT say "My .htaccess is perfect". Nope! It's working fine for me. So, I hopefully it will work fine for you too!

3 - You can (need) tweak it for your own needs.

4 - My dozen of intermediary steps to get the few final points (for gaining the Grade A) are so terrible for a human being, that I prefer to NEVER publish them.
Now, your CS-Cart website should be faster! Posted Image

Thanks for reading,


Lee Li Pop

PS: Today, I found a freeware who can beat all the expensive "website accelerators" like WEBO, and how to use it for profit.

Keep in touch with Lee Li Pop speed up channel!

.
If All Else Fails, Read The Instruction Manual! Knowledge Base 2.x + CS-Cart Instruction Manual

Hosted at Pair.com since 2000. Zero hacking attempts during first 11 years... And counting!

 

Posted 18 November 2010 - 08:29 PM #2

Hi Lee,

Just wanted to say thank you for all these great tips you have given us all.

Quick question about the above .htaccess file. Is this for use with Smartoptimizer?

Thanks

John
Take everything you like seriously, except yourselves. - Rudyard Kipling

 
  • Lee Li Pop
  • Senior Member
  • Members
  • Join Date: 07-Mar 08
  • 941 posts

Posted 19 November 2010 - 01:33 AM #3

Hello John,

Yes, if you read Step 2, and SmartOptimizer Source Code Disclosure Vulnerability, you will understand that I use SmartOptimizer, thus, yes, this ".htaccess" above is for running with SmartOptimizer.

However, John, update your SmartOptimizer for v1.8, and (try) to use a reliable web hosting company to have a fully secure cart:

Hello The Tool,

Here is the response I received from Ali Farhadi concerning the added htaccess file in SO.

But seems some hosts including yours doesn't allow using php_value in .htaccess which causes it to break.


Of course, use this ".htaccess" in addition of Step 1 and Step 2 to get the full power of my tweaks!

Happy to help!


Lee Li Pop
.
If All Else Fails, Read The Instruction Manual! Knowledge Base 2.x + CS-Cart Instruction Manual

Hosted at Pair.com since 2000. Zero hacking attempts during first 11 years... And counting!

 

Posted 20 November 2010 - 06:01 PM #4

Hi Lee,

Thanks for all your tips.

I'm testing with CS Cart at the moment so have just added the .htaccess you provided.

Just a quick question, do you have eAccelerator installed and active on your server?
If so, do you have optimization and cache enabled?

Also, what type of caching have you selected in CS Cart?

Thanks

John
Take everything you like seriously, except yourselves. - Rudyard Kipling

 
  • Lee Li Pop
  • Senior Member
  • Members
  • Join Date: 07-Mar 08
  • 941 posts

Posted 20 November 2010 - 08:43 PM #5

Hello John,

I'm testing with CS Cart at the moment so have just added the .htaccess you provided.


This ".htaccess" performs its best performances coupled with Step 1 and Step 2 ;)

Just a quick question, do you have eAccelerator installed and active on your server?


No I don't, because I'm on a shared.

However, if I could afford a dedicated server or a VPS, I would use Alternative PHP Cache, because it will be included built-in to the core of PHP starting with PHP 6.

Source: http://en.wikipedia....HP_accelerators

On the other hand, the speed of my sites is very good, so I stay on a shared.

Also, what type of caching have you selected in CS Cart?


I use mainly CS-Cart 1.3.5. It seems to me, there is NO cache there.

All my results that I talk, are based on CSC 1.3.5, however, it's a personal release, very light with "performance" in mind.

Why "very light"?

Because I have only one CSS file. I cleaned and grouped the CSS code, and deleted all useless background images. Thereby, it weighs only 13Kb.

Thanks for all your tips.


You're welcome,


Lee Li Pop
.
If All Else Fails, Read The Instruction Manual! Knowledge Base 2.x + CS-Cart Instruction Manual

Hosted at Pair.com since 2000. Zero hacking attempts during first 11 years... And counting!

 
  • maksis
  • Junior Member
  • Members
  • Join Date: 04-Apr 10
  • 24 posts

Posted 23 November 2010 - 01:50 PM #6

Hi LEE

Thanks for your advices, but as I get to step to of your tips and change htaccess file it messes all my tamplate what should I do?

Thanks!!

 
  • Lee Li Pop
  • Senior Member
  • Members
  • Join Date: 07-Mar 08
  • 941 posts

Posted 23 November 2010 - 04:15 PM #7

Hello Maksis,

it messes all my tamplate what should I do?


Sorry, I am not an English speaker. I don't understand "It messes".


Lee Li Pop
.
If All Else Fails, Read The Instruction Manual! Knowledge Base 2.x + CS-Cart Instruction Manual

Hosted at Pair.com since 2000. Zero hacking attempts during first 11 years... And counting!

 
  • brandonvd
  • is Super Awesome
  • Members
  • Join Date: 19-Dec 06
  • 2633 posts

Posted 23 November 2010 - 05:32 PM #8

Lee Li,

Messes = Messes up, Screws up, Doesn't work, Looks like crap.

Maksis,

Lee Li's .htaccess should work fine for you. My guess is that you still have the smartoptimizer .htaccess file inside the smartoptimizer folder. Remove it, clear your cache and see what happens.

Brandon

 
  • Lee Li Pop
  • Senior Member
  • Members
  • Join Date: 07-Mar 08
  • 941 posts

Posted 23 November 2010 - 05:46 PM #9

Hello Brandon,

Thank you for your explanations!

So, I understand "Doesn't work" ;)

So, Brandon, did you install this ".htaccess"?

If so, did you noted any increasing of your Yslow!?


Lee Li Pop
.
If All Else Fails, Read The Instruction Manual! Knowledge Base 2.x + CS-Cart Instruction Manual

Hosted at Pair.com since 2000. Zero hacking attempts during first 11 years... And counting!

 
  • brandonvd
  • is Super Awesome
  • Members
  • Join Date: 19-Dec 06
  • 2633 posts

Posted 23 November 2010 - 06:40 PM #10

Lee Li,

I did install this .htaccess, but I didn't notice any difference. My old .htaccess was pretty similar so that is probably why.

I did learn something though. I guess there are two types of yslow. There is a version 1 and a version 2. Apparently http://gtmetrix.com/ uses version 1 and gave me a "B" grade. When I run yslow on Firefox it shows that version 2 is an "A" and version 1 is a "B".

Either way, I'm pretty happy. I never got that good of grades in school so if I'm getting A's and B's for my website than I must be doing something right.

I do appreciate your posts on speeding up the sites though. I did notice that doing things like enabling gzip along with smartoptimizer my site speed really increased.

Brandon

 
  • Lee Li Pop
  • Senior Member
  • Members
  • Join Date: 07-Mar 08
  • 941 posts

Posted 23 November 2010 - 08:10 PM #11

Hello Brandon,

You're absolutely right about Yslow!

So,

1 - Did you implemented this advice about the head flush()?

http://forum.cs-cart...97219#post97219

2 - Did you minified and combined your CSS and Javascript files?

3 - Did you studied your "Waterfall View" from WebPageTest?

http://www.webpagetest.org/

You can get a Yslow! Grade A with release 2, because I did!

Much more, do you know if you call an external Javascript as I explain in this post, you loose up to 4 points!?

http://forum.cs-cart...2270#post102270

Now, I work on implementation of Content Delivery Network (CDN) for CS-Cart... The game is not over, because I haven't won yet...



Lee Li Pop
.
If All Else Fails, Read The Instruction Manual! Knowledge Base 2.x + CS-Cart Instruction Manual

Hosted at Pair.com since 2000. Zero hacking attempts during first 11 years... And counting!

 
  • brandonvd
  • is Super Awesome
  • Members
  • Join Date: 19-Dec 06
  • 2633 posts

Posted 23 November 2010 - 08:41 PM #12

Lee Li,

I guess I missed the flush thing. I might have to take a look at it.

As for combining the JS and CSS files, I thought about it. I decided that upgrading my site is enough work already and I don't really want to have to make more work for myself. There is no doubt that if I were to combine my CSS files that upgrading would be a huge pain in the neck for me where right now it is only a small pain.

I have kind of looked over the WebPageTest. I know that some simple things like optimizing some of my images will help.

I'd love to find out more about the CDN. For some reason my simple mind can't figure out exactly how this works. No surprise I guess.

Brandon

 
  • Ion_Cannon
  • Senior Member
  • Members
  • Join Date: 28-Oct 09
  • 178 posts

Posted 24 November 2010 - 12:48 AM #13

Lee Li, have you had any experience with "Xcache"?? I have been running it for 6 months. In Google Web Master tools my site went from Slow to Fast in the Labs section after I installed it so there is some benefit but I wondered if anyone else had tried it out.
--
Lolita Glasses
Currently Running: CS-Cart 2.2.4

 
  • Lee Li Pop
  • Senior Member
  • Members
  • Join Date: 07-Mar 08
  • 941 posts

Posted 24 November 2010 - 03:45 AM #14

Hello Brandon,

I guess I missed the flush thing. I might have to take a look at it.


With this simple added code, your website is faster to 1/2 second.

*****
Hello Ion Cannon,

Lee Li, have you had any experience with "Xcache"??


I would like, but I can't, because I'm on a shared server...

However, if I could to use a PHP accelerator, I will choose APC, although eAccelerator is faster, because APC will be bundled in by default in PHP6.

It maybe possible to install a PHP accelerator in a shared hosting, but I do not know it.


Lee Li Pop
.
If All Else Fails, Read The Instruction Manual! Knowledge Base 2.x + CS-Cart Instruction Manual

Hosted at Pair.com since 2000. Zero hacking attempts during first 11 years... And counting!

 
  • maksis
  • Junior Member
  • Members
  • Join Date: 04-Apr 10
  • 24 posts

Posted 24 November 2010 - 12:15 PM #15

Hello Lee!

Thanks for your tips, at the beginning I got grades D and D now its C and C.


I am wondering how can I make fewer requests on my website?

Thanks again!

 
  • maksis
  • Junior Member
  • Members
  • Join Date: 04-Apr 10
  • 24 posts

Posted 24 November 2010 - 02:34 PM #16

Also as I put this code in my htaccess file I get 500 Erorr
</IfModule>	

<IfModule !mod_expires.c>
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*\.(ico|gif|jpg|jpeg|png|swf|css|js|html?|xml|txt))$ smartoptimizer/?$1
</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 private
</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>


 
  • Lee Li Pop
  • Senior Member
  • Members
  • Join Date: 07-Mar 08
  • 941 posts

Posted 24 November 2010 - 06:24 PM #17

Hello Maksis,

1 - Do you have Gzip running perfectly?

Test your page for gzip compression:

http://www.whatsmyip...tp_compression/

2 - Do you have SmartOptimizer running perfectly?

3 - Could you publish your FULL ".htaccess"?

Thank you,


Lee Li Pop
.
If All Else Fails, Read The Instruction Manual! Knowledge Base 2.x + CS-Cart Instruction Manual

Hosted at Pair.com since 2000. Zero hacking attempts during first 11 years... And counting!

 
  • maksis
  • Junior Member
  • Members
  • Join Date: 04-Apr 10
  • 24 posts

Posted 25 November 2010 - 08:01 AM #18

Hello Lee!

yesterday afternoon I managed to get B and C grades

1) yes my gzip is running perfectly!

2) I do have smartoptimazer but I dont know if its running perfectly.

3) Here is my full htaccess file
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]
RewriteRule ^(.*\.(js|css))$ smartoptimizer/?$1

RewriteCond %{REQUEST_FILENAME} .*\/catalog\/.*
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteRule . index.php?sef_rewrite=1 [L,QSA]

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# Or, compress certain file types by extension:
<Files *.html>
SetOutputFilter DEFLATE
</Files>

</IfModule>
<IfModule mod_deflate.c>
<FilesMatch "\.(php|html)$">
SetOutputFilter DEFLATE
</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
ExpiresByType application/msword A315360000
ExpiresByType application/rtf A315360000
ExpiresByType application/vnd.ms-excel A315360000
ExpiresByType application/vnd.ms-powerpoint A315360000


 

Posted 25 November 2010 - 03:09 PM #19

Hello Brandon,



With this simple added code, your website is faster to 1/2 second.


I tried this code out, I don't really have a clue about it but thought I would try it.

I don't think it works correctly on my site though. Is it the

/skins/YOUR_SKIN/customer/index.tpl file that you ad this too?

When I compare the output I get for my site with chunkview shows basically the whole of my index page in chunk form-about 23 of them.

Was worth a try :-)

Thanks again Lee for more great suggestions.
Take everything you like seriously, except yourselves. - Rudyard Kipling

 
  • Lee Li Pop
  • Senior Member
  • Members
  • Join Date: 07-Mar 08
  • 941 posts

Posted 25 November 2010 - 04:26 PM #20

Hello Maksis,

Your ".htaccess" is too different than mine.

Please use mine.

Of course, try it on your developing box (localhost) and check your Yslow! score before/after with Yslow! for firefox:

http://developer.yahoo.com/yslow/

If you have NOT a developing box, install WAMP or XAMPP.

I use WAMP on my Windows box for years, and recommend it.

If you have a Linux box, follow my advices here:

http://forum.cs-cart...38759#post38759

Sorry, I am not a Mac Maniac :oops:

All the best,


Lee Li Pop
.
If All Else Fails, Read The Instruction Manual! Knowledge Base 2.x + CS-Cart Instruction Manual

Hosted at Pair.com since 2000. Zero hacking attempts during first 11 years... And counting!