The speed and stability of your web servers is crucial for optimal user experience. Fortunately, there is a solution that ensures the stability and speed of your servers at all times: caching, i.e. storing frequently requested static content.
Varnish is the most widely used caching technology (and, in many cases, also the most recommended).
Varnish is a unique form of caching. It caches entire web pages to make a website faster. Varnish captures the HTTP traffic destined for the web application and serves cached pages to the visitors. This way, the application is no longer overloaded and stability is guaranteed.
In addition to Varnish, there are other caching technologies, such as Redis, OPcache and APCu.
Fun fact: Varnish was originally built as a custom solution to speed up the Norwegian online newspaper www.vg.no, and it is now used by millions of websites worldwide.
Caching helps reduce the load on your resources and maintain the stability and speed of your application. It allows data to be stored in a calculated format for later use. This way, the same request does not have to be reprocessed each time.More info
The benefits of Varnish are obvious: it ensures the speed, stability and performance of your web application.
Varnish can handle a large number of simultaneous connections and uses very little memory. Varnish's CPU usage is also very low. Varnish only focuses on caching and offers few other features. This makes the architecture very efficient.
Varnish caches entire pages to reduce the load on the server. The fact that the cached items are stored in RAM makes this system remarkably fast.
A single Varnish server delivers outstanding performance:
Varnish acts as a web server (between the user and the web application) and communicates via the HTTP protocol. This way, HTTP traffic is not directly sent to the web application but is diverted to Varnish instead.
Unlike other caching technologies, Varnish caches entire web pages. Since these pages are cached separately, they do not have to be requested from the server when the web page is visited again, making the page much faster to display.
When a user wants to access a web page that has not yet been cached, Varnish will connect to the web application and forward the original request. The HTTP output of the requested web page that the web application forwards is stored in Varnish.
This information remains cached as long as the Time To Live has not expired. This Time To Live (TTL) is determined by the "Cache-Control" header. This header is part of the web application's HTTP response and is used by Varnish to determine how long the web page may be cached.
Varnish will only return cached web pages if it is certain that the content is not private. When authentication is required or a cookie is used, the response is only suitable for the user in question and not for the rest of the visitors. In this case, Varnish will not cache the specific web page.
It is not always necessary to cache a web page. The web application can decide that a page should not be cached.
In addition, Varnish has some internal rules that determine when to cache the data and when not to cache them:
Varnish can decide to bypass the cache and still send the request to the web server. Even if the requested web page is stored in the cache.
VCL is a special programming language that can be used to configure the caching behaviour of Varnish.
VCL can be used for the following tasks:
The VCL code is contained in a VCL file located on the Varnish server.
Without Varnish, a user's request will be sent directly to the web application. When implementing Varnish, a Varnish server will come in between.
Theoretically, if you want to enable Varnish, all you need to do is make sure that the "www" DNS record of your domain name points to the Varnish server. If your application complies with the HTTP caching rules, the rest will not cause any problems. Getting started with Varnish is just that simple.
In practice, you need to check carefully how your web application handles HTTP:
In specific situations, some objects must be explicitly removed from the cache.
Just think, for example, of the front page of a news site. When there is breaking news, the news site cannot wait for the TTL of the cached content to expire. The pages in question must therefore be removed from the cache immediately.
For this, you can count on VCL.
Common platforms such as WordPress, Drupal, Joomla and Magento offer VCL templates that take the behaviour of the framework in question into account.
Combell's experts have learned all there is to know about Varnish. Together with you, we look for the best solution for your specific application. We are also at your disposal for other caching solutions. As an extension to our web hosting packages or as a tailored solution to optimise the performance of your application.
For years, Combell has been committed to achieving fast loading times and optimal user experience by means of caching solutions, including the popular Varnish.
Together with you, we look for the best solution for your website or application. Our experienced specialists are responsible for selecting and implementing the best caching solution.