Jamersan | Magento and BigCommerce Elite Partner Agency

Site Speed and Magento

Optimizing website response time is one of the most confusing aspects of running a Magento website. Many variables go into this problem: hardware, bandwidth, application layer, cloud services, database engines, load balancing, etc. For a shop owner, or even a developer, getting the environment right can be an impossibly confusing nightmare – even for one who is otherwise well-equipped to maintain and operate a Magento store.

The general consensus is that the faster a website loads, the more successful it will be in retaining visitors and converting goals. Site speed is also a critical factor in search engine ranking. When looking at ways to improve a site’s speed performance, we consider all kinds of caching – temporarily stored data on a computer’s file system or in its memory that is more quickly retrieved than the same dynamically created content it replaces.

There are a few kinds of caching that can be used in conjunction to fully and ideally optimize a site.

  • opcode – Alternative PHP Cache (APC) is an opcode cache. Integrated at the server level, it optimizes the PHP code itself.
  • cache systems for back-end and session stores – Magento /var/cache, Memcache, Remote Dictionary Server (Redis) are generic cache systems that integrate with Magento and which cache data to a file system or memory. You can use only one backend cache with Magento. You can use only one session store with Magento. My recommendation is to use Redis for the back-end cache system and session store. Memcache is an in-memory key/value store. Redis is a data structure server (which can act like a key/value store).  Magento /var/cache is the cache system built into Magento.
  • reverse proxy cache – Varnish caches responses at the server level. Magento 2 is designed to run with it and Magento 1 will need plugins such as Turpentine.

 

Magento Core Functionality

The least-effective, slowest cache system relies entirely on the file system. Although, if your server has Solid State Drives (SSDs), this is not necessarily true any longer. In Magento, the built in file system caching functionality stores its files in /var/cache. This cache grows as the number of products in your store grows, so a larger store will have a very slow cache system if using only the built in caching. A store with 10 products will be very fast with this cache. A store with 1000 will not.

Magento Enterprise Edition(EE) comes with a built-in full page cache. The Full Page Cache (FPC) allows you to cache pages that do not have dynamic content.  This cache will enable the pages to serve very quickly by comparison. It is possible to pass arguments to a dynamic block container and retain most of the advantage of full page caching on pages with a little dynamic content by either using Edge Side Includes (ESI, otherwise known as ‘hole punching’) or asynchronous JavaScript and XML (AJAX). (See Stack Overflow, “How do I include a dynamic block in the product page with full page caching turned on?” )

When used with a reverse proxy cache, the FPC can improve an already fast site’s performance by reducing resource usage. You can, and probably should, use a FPC and a reverse proxy cache – contrary to popular belief, perhaps. The reverse proxy cache is not application aware, but the FPC has direct access to the user session and the Magento core. Thus, they handle different situations and complement each other.

 

Back-end Cache Systems

Prior to Redis 3.0, there may have been strong arguments for Memcache over Redis. Now, however, Redis is the preferred method for caching because it is a data structure server and not “just” a key-value store. It offers significantly more scalability, functionality, persistence, optimistic locking, clustering, and powerful data types, and more.

For a site with significant product count or volume it is highly recommended to use Redis in lieu of Magento’s file-based caching system.

The following Magento editions support Redis session and back end caching:

  • Enterprise Edition (EE) 1.13 and later
  • Community Edition (CE) 1.8

 

Varnish

Varnish is a reverse proxy HTTP accelerator. It is a separate service entirely (and can be on a separate web server, even). Think of it as a transparent go-between between anonymous traffic and the web server back-end. It can provide the fastest possible page load times on this kind of traffic achievable (if configured properly).

Varnish handles all of the incoming anonymous requests to your Magento shop. If it has served the page before, it sends the cached version right away, and the traffic never even gets to your database or web server (Apache, Nginx, whatever).

Varnish can also act as a load balancer.

 

Summary

Server optimization and site speed is a confusing yet critical aspect of a successful web presence. Don’t make the mistake of waiting to see what happens – plan for efficient, effective caching as part of every project. It may also help to consult with one of our Magento Certified Solution Specialists, who can guide you on the right path to a successful Magento store.

Our Leadership

TJ Gamble

CEO

Shane Rodgers

Director, Operations

Alex Schreck

Director, Sales & Partnerships

Dave Christy BigCommerce & Adobe Expert

Dave Christy

Director, Delivery