Make your OpenCart Shopping Cart Faster RIGHT NOW!

This is a post dedicated to making OpenCart faster.   I am going to list in depth and in priority order the things that you can do to make your OpenCart install go much faster.  As a disclaimer, please backup all your files prior to doing any of this.  I am also not responsible if your cart goes down as a result of any of my recommendations.

EASY (low risk of damaging site if done incorrectly):

1.) Optimize images by running PNG’s through tinypng.com, or saving your JPG or GIF as web optimized in photoshop to reduce file size.  The overall goal here is to reduce the footprint of each page.

2.)  Disable and Uninstall any of the features/plugins you aren’t using through the admin interface.

3.) Minify JSS and CSS (JSS Minifier, CSS Minifier) to increase load time.

4.) Run your website through two speedtests: Pingdom and Web Page Test.  If Web Page test says your time to first byte is greater than 3 or 4 seconds, switch to a different host.  Think about getting a dedicated server or virtual dedicated.

5.) Implement a CDN.  Change any files that get used more than once in your layouts to point to files in the CDN.  For non enterprise level carts, I recommend Cloud Files by Rackspace (which is actually Akami).  Most of these changes will live in your catalog/view/theme/default/template/common/header.tpl and footer.tpl.

MODERATE (medium risk of damaging site if done incorrectly):

1.) Add index’s to your table to optimize your database.  Full Article here: http://forum.opencart.com/viewtopic.php?f=121&t=107756

2.) Implement caching in your htaccess so your user’s don’t have to redownload files on every page they visit.

Paste the following into your htaccess file:

# turn on the module for this directory
<IfModule mod_expires.c>
ExpiresActive on
# set default
ExpiresDefault “access plus 24 hours”
ExpiresByType image/jpg “access plus 1 months”
ExpiresByType image/gif “access plus 1 months”
ExpiresByType image/jpeg “access plus 1 months”
ExpiresByType image/png “access plus 1 months”
ExpiresByType text/css “access plus 1 months”
ExpiresByType text/javascript “access plus 1 months”
ExpiresByType application/javascript “access plus 1 months”
ExpiresByType application/x-shockwave-flash “access plus 1 months”
</IfModule>

DIFFICULT (doing anything wrong in here will white screen your website)

1.) Comment out any unnecessary items in your catalog/controller/common/header.php and footer.tpl (back this file up first).   Examples of things I have removed without breaking the cart:

$this->data[‘categories’] = $this->getCategories(0);  //<-this made a big improvement

$results = $this->model_localisation_language->getLanguages(); <-was able to remove this because I am serving only english on my site

$results = $this->model_localisation_currency->getCurrencies(); <-was able to remove this because only accepting the US dollar

I have done several other things to this file but my installs are custom and I hard code things like to logo, favicon and other no brainer items.  By hard coding these in the header, you can get rid of the loops and all the queries it takes to resolve these on every page load.  This improves load time significantly.

Let me know if you have any questions, I would be happy to help.

Benefits of using a CDN (Content Delivery Network): My Analysis

Why should I use a CDN….is it it worth it?  You may be asking yourself this question.  My answer to this questions is YES, you should use a CDN and here is why.  Upon deciding to use a CDN, we researched several of the top companies.  The companies included Akami, Cloudflare, Amazon Cloud Front, EdgeCast and MaxCDN.

Our requirements were very simple for our CDN, we required an origin PULL style CDN that also allowed us to purge our files through an easy to use API.  What this means (origin PULL) is, if the asset that the user is looking for isn’t currently on the CDN for any reason, the CDN will pull (from the origin..usually www.) it off of the www version of our site automatically with no impact in speed to the user.  Also, being able to purge through an API was critical as the particular site that needed this has a custom CMS where the administrators are constantly updating images and other assets on the fly.

Our example use case for a PULL CDN:

User requests http://cdn.somesite.com/jquery.js and it’s the file isn’t there.  The CDN will automatically request http://www.somesite.com/jquery.js from our regular site, download, compress it and cache it on there servers.

In our initial testing, even when the CDN had to request our file from our site it was just as fast as if it was downloading from our site anyways.

After getting the initial pricing for this, Akami was instantly out as we couldn’t get into a plan for less than about $1500 a month.  This was a little out of our price range even though they seem to have to market share of all the larger companies.

After various reasons of not choosing the other CDN providers, EdgeCast was the fastest in getting back to us and there technical team was very helpful in getting the CDN launched very quickly.  They also had very competitive pricing and seemed to want to grow with us in terms of contract etc…  Also, since we are predominantly US based at the moment, we were very happy with there coverage here (and in Canada).

Once selecting EdgeCast, we were able to get up and running very quickly on the CDN.  We use Symfony Framework in the particular application so setting up the CDN was as simple as a configuration change to replace www. with cdn. on all image/css/js assets throughout the whole site.  From start to finish, our production environment (including SSL traffic) was up and running in about 2 days.

The site that we implemented the CDN now loads in less than 1 second.  Before we implemented the CDN it took about 1.25 second to load the site.  Here is a snapshot of what the Pingdom Website Speed Test says about our site after the CDN implementation.  Keep in mind, this particular site is an extremely complex application that sees more than 15,000 visits per day with an average of 5 page view per visit!

Website Speedtest Screenshot

 

 

 

One thing to notice also, is our New Relic score went up slightly, but we scored near perfect prior to implementing the CDN.

My First Post in a long time

This is my first post.  It’s going to be a short one, but it’s here.   I plan on sharing my thoughts, experiences and advice on several topics ranging from enterprise level web development all the way down to how to play a particular poker hand.

Here’s a little bit about me:

I am married to a wonderful woman who gladly puts up with all of my shit (which I am very thankful for) and I have a very energetic son who keeps my wife and myself very busy.  I work for an ecommerce website (won’t mention the name for the sake of this being indexed with the name of the company) and I also own a website company based out of Scottsdale Arizona.  Nearly all of my time is spent working for this ecommerce company, with any of the remainder (which is little) being spent on the web company.  The ecommerce company that I work for is the fastest growing company I have ever worked for, dealt with or been a part of.  We grow at a speed that doesn’t exist in business, and it’s actually quite exciting.  The reason for our growth really boils down to a few things…a passionate/knowledgeable CEO, passionate associates at the company who care ALOT about the future and finally being well capitalized and positioned within our market.  I am very fortunate as I love what I do (if you don’t I recommend trying it) and am learning new things every day.  I am surrounded by great people in both places and am fortunate to only be able to provide value but also get to glean good information from my peers.

If I am not working, I am usually spending time with my family, friends or trying to squeeze a poker session in here and there.  Spending time with my son/wife, and playing poker are really the only two activities that I allows my mind to escape from work.  But as I said before, i really enjoy what I do so it doesn’t always feel like work… (unless something is down and this happens).

I look forward to sharing my thoughts on various topics, feel free to comments or ask questions.