Best Server-side Caching Solutions For Hosting Your Websites
Last updated on May 23, 2017
When it comes to web hosting, speed matters the most. If your server is slow, your site will not perform well. Therefore, many web hosts go out of their way to ensure that their servers utilize the latest tools and resources to host your data.
One such method is to make use of server-side caching. You might have heard of web hosts speaking about “solutions” such as Memcached, xCache, Varnish and what not. Each promises to make your website lightning fast — “up to 200 times faster” in some claims!
But what are such caching solutions all about? And how can they benefit your website? In this article, I will explain some of the leading server-side caching solutions so that the next time you hear about either of such methods, you know exactly what to expect!
The first entry on our list, Memcached, is an open source memory object caching system. In other words, it relies on distributed memory caching to load your database-driven websites faster.
Confused already? Put it this way: if you are running a simple HTML website with no databases and no dynamic data, Memcached is probably not going to help you much. However, if you are running a database-driven website, such as those built using a CMS like WordPress, Drupal, concrete5 and so on, Memcached can drastically improve the performance of your site.
How does it work? Memcached follows a very simple concept: it takes chunks or parts of your website’s database calls, and holds them in the memory itself. Thus, each time your website tries to perform a database-based action, say a contact form or likewise, Memcached makes use of data from the memory. This saves an extra call to the database server and improves your website’s speed.
Memcached is free and open source, so if your web host asks you to pay extra for it, they aren’t indulging in fair business practice.
Redis is another caching solution that stores your database activity in the memory to boost up page load times. Redis has long had a great reputation in the world of server-side caching and you will notice considerable speed improvements when relying on Redis.
That said, Redis has an added advantage in the sense that languages such as PHP and Node.js come with native Redis bindings. This means PHP-based software, like WordPress, tend to work seamlessly better on a Redis-based server, all other things being constant.
Redis is also an open source solution that costs no extra money.
Varnish is a web application accelerator, or as it likes to define itself, “caching HTTP reverse proxy.”
Lost in the jargon? In simple words, Varnish is a caching mechanism that stores data in virtual memory, but does not actively work on it. Instead, it leaves the task of deciding what gets cached to memory and what is left to the disk with the operating system. Another concept that is worth noting is that Varnish is not a pure server-side solution. Instead, it is an HTTP accelerator — so if you access your database-driven website’s data via FTP or any other protocol, chances are that you won’t really be getting the speed boosts provided by Varnish.
Varnish is open source and free to use. Many “managed” web hosting providers tend to rely on on Varnish to improve the performance of websites.
4. PHP Code Caching
PHP code caching is not really a single server-side caching solution. Instead, it is a conglomerate of various PHP-based solutions. PHP extensions such as xCache, OPCache and APC are well known names in this field.
Such PHP extensions, when enabled, tend to cache the PHP processes as and when needed. Thus, your website does not need to re-process the cached PHP processes. This saves a good deal of time and server resources and significantly boosts up your website. For example, let’s say a given PHP script is compiled multiple times. Now, extensions such as OPCache or xCache can cache the said script when it is compiled for the first time, and for subsequent uses, the cached copy can be used to speed up the compilation process.
Naturally, PHP code caching works only if your website uses PHP processes. If you are not working with a PHP script, there is no use for caching extensions for PHP.
So, which server-side caching solution should you really use? Even more importantly, now that you know, generally speaking, what each popular server-side caching mechanism does, you can make a wiser choice for your website depending on the needs and requirements.
PHP extensions tend to be very helpful, especially if you are on shared hosting. Most shared web hosting plans come with rigid limits on the number of concurrent PHP processes, and having a caching solution can help you ensure that resource usage limits are not touched. As long as you use a recent version of PHP, you must be able to utilize the PHP caching extensions on virtually every web host.
The other caching solutions are often provided by web hosts for shared and reseller plans. On VPS and Dedicated servers, you can choose to install and set them up yourself. HawkHost, for example, offers Memcached on shared and reseller plans. Similarly, Namecheap offers xCache on its Business hosting plan.
Which server-side caching solution does your web hosting provider offer? Have you asked your web host about it, or did you dismiss it as a marketing gimmick? Share your views in the comments below!
Sufyan is a contributor to a variety of websites and blogs about technology, Linux, open source, web design, content management systems and web development. Learn more about his works on sufyanism.com