Magento is fast, but, each time a Magento page is built and loaded, billions of instructions are executed on the server’s CPU and memory resources are consumed. On a busy server, that can lead to slow page loads and insufficient resources to serve every page quickly.
The solution is caching. When pages — or parts of pages — are cached, instead of being recreated every time a user requests a new page, they are served from the cache. Caches save the product of earlier page builds, so that when a request for the same page is received, the cached version can be served. Caching both increases the speed at which pages can be sent to users, and reduces the load on the server.
While Magento has some advanced caching technology built in, it’s often better to move the overhead of caching to a separate dedicated application. In this article, I’d like to look at one option for external caching: the caching reverse proxy.
First off, what’s a reverse proxy? A proxy is a server that stands between clients (usually a web browser in this case) and other servers. It accepts requests from clients and makes requests to other servers. Essentially, a proxy mediates communication between the client and other parts of a network.
A reverse proxy is a specific type of proxy. It accepts requests on behalf of a one or more servers, passes those requests on to the servers, and passes the data returned by those servers back to the client. In this case the servers are Magento servers and the clients are web browsers. A firewall or a load balancer can also be considered types of reverse proxy.
Now to the interesting part. Because the reverse proxy stands between the client and the server, it can mediate the flow of data between the two. So, a caching reverse proxy situated between a web browser and a Magento installation is capable of caching some of the pages created by Magento, returning them to the browser without the Magento application having to do anything. Caching reverse proxies of this type are also known as web accelerators, for obvious reasons.
A typical example of a caching reverse proxy used with Magento is Varnish. On its own, Varnish doesn’t work particularly well with Magento, but we created a Magento plugin called Turpentine that improves Magento / Varnish integration.
It should be mentioned that not everything can be cached. Much of the core eCommerce experience is necessarily dynamic — the shopping cart for example. A reverse caching proxy can’t do much to speed up those operations. It can, however, improve performance on product pages and other essentially static resources. It can also reduce the burden of generating these pages so that more resources are available for the parts of the eCommerce process that must be generated at request-time.
The result is more efficient resource use and more responsive shopping cart and administration interfaces when a Magento store is under heavy load.