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

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.

[SIZE=“3”]Therefore, I wish you a merry Christmas![/SIZE]


```php DirectoryIndex index.html index.php





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







RewriteCond %{REQUEST_FILENAME} -f

RewriteRule ^(.
.(ico|gif|jpg|jpeg|png|swf|css|js|html?|xml|txt))$ smartoptimizer/?$1









ExpiresActive On

ExpiresDefault “access plus 10 years”











Header append Vary User-Agent

Header append Vary Accept-Encoding

Header append Cache-Control private





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

ExpiresByType application/msword A315360000

ExpiresByType application/rtf A315360000

ExpiresByType application/vnd.ms-excel A315360000

ExpiresByType application/vnd.ms-powerpoint A315360000



FileETag none





SetOutputFilter DEFLATE





```



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.

[SIZE=“3”]Now, your CS-Cart website should be faster![/SIZE]



Thanks for reading,





Lee Li Pop



[SIZE=“3”]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![/SIZE]

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

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:


[quote name=‘Lee Li Pop’]Hello The Tool,

[quote name=‘The Tool’]Here is the response I received from Ali Farhadi concerning the added htaccess file in SO.

[quote name=‘Ali Farhadi’]

But seems [SIZE=“3”]some hosts including yours doesn’t allow using php_value in .htaccess[/SIZE] which causes it to break.[/QUOTE][/QUOTE][/QUOTE]



[SIZE=“3”]Of course, use this “.htaccess” in addition of Step 1 and Step 2 to get the full power of my tweaks![/SIZE]



Happy to help!





Lee Li Pop

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

Hello John,


[quote name=‘utilityempire’]

I’m testing with CS Cart at the moment so have just added the .htaccess you provided.[/QUOTE]



[SIZE=“3”]This “.htaccess” performs its best performances coupled with Step 1 and Step 2[/SIZE] :wink:


[quote name=‘utilityempire’]

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



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: [url]http://en.wikipedia.org/wiki/List_of_PHP_accelerators[/url]



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


[quote name=‘utilityempire’]

Also, what type of caching have you selected in CS Cart?[/QUOTE]



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.


[quote name=‘utilityempire’]

Thanks for all your tips.[/QUOTE]



You’re welcome,





Lee Li Pop

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!!

Hello Maksis,


[quote name=‘maksis’][COLOR=“Red”]it messes[/COLOR] all my tamplate what should I do?[/QUOTE]



Sorry, I am not an English speaker. I don’t understand “[COLOR=”#ff0000"]It messes[/COLOR]".





Lee Li Pop

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

Hello Brandon,



Thank you for your explanations!



So, I understand “Doesn’t work” :wink:



So, Brandon, did you install this “.htaccess”?



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





Lee Li Pop

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 [url]http://gtmetrix.com/[/url] 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

Hello Brandon,



You’re absolutely right about Yslow!



So,



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



[url]http://forum.cs-cart.com/showthread.php?p=97219#post97219[/url]



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



3 - Did you studied your “Waterfall View” from WebPageTest?



[url]http://www.webpagetest.org/[/url]



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!?



[url]http://forum.cs-cart.com/showthread.php?p=102270#post102270[/url]



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

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

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.

Hello Brandon,


[quote name=‘brandonvd’]I guess I missed the flush thing. I might have to take a look at it.[/QUOTE]



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



*****

Hello Ion Cannon,


[quote name=‘Ion_Cannon’]Lee Li, have you had any experience with “Xcache”??[/QUOTE]



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.



[SIZE=“3”]It maybe possible to install a PHP accelerator in a shared hosting, but I do not know it.[/SIZE]





Lee Li Pop

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!

Also as I put this code in my htaccess file I get 500 Erorr

```php





RewriteCond %{REQUEST_FILENAME} -f

RewriteRule ^(.*.(ico|gif|jpg|jpeg|png|swf|css|js|html?|xml|txt))$ smartoptimizer/?$1









ExpiresActive On

ExpiresDefault “access plus 10 years”











Header append Vary User-Agent

Header append Vary Accept-Encoding

Header append Cache-Control private





Header append Cache-Control public





Header unset ETag

FileETag None



```

Hello Maksis,



1 - Do you have Gzip running perfectly?

[quote name=‘Lee Li Pop’]

Test your page for gzip compression:



[url]http://www.whatsmyip.org/http_compression/[/url]

[/QUOTE]

2 - Do you have SmartOptimizer running perfectly?



3 - Could you publish your [COLOR=“Red”]FULL[/COLOR] “.htaccess”?



Thank you,





Lee Li Pop

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

    ```php 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]

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:



SetOutputFilter DEFLATE











SetOutputFilter DEFLATE






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

ExpiresByType application/msword A315360000

ExpiresByType application/rtf A315360000

ExpiresByType application/vnd.ms-excel A315360000

ExpiresByType application/vnd.ms-powerpoint A315360000

```

[quote name=‘Lee Li Pop’]Hello Brandon,







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



[/QUOTE]



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 :slight_smile:



Thanks again Lee for more great suggestions.

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:



[url]http://developer.yahoo.com/yslow/[/url]



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:



[url]http://forum.cs-cart.com/showthread.php?p=38759#post38759[/url]



Sorry, I am not a Mac Maniac :oops:



All the best,





Lee Li Pop