Varnish cache and your website - enjoy it or hate it. It is up to you but let us read about it and see what it is.
We are pretty sure that you do not like slow websites. You maybe even hate them. Slow websites are annoying and in specific situation they can make us very angry and disappointed. That is of course a very normal experience.
How does a website become slow? Actually there are some rules or recommendations that tell us what to think about in web development. If we try to follow them our website will be fast enough so no one gets tired of it. Two important and basic details are:
Images and files - Do not use big images or other files that can be embedded.
Text in content - A huge amount of text in one page can also affect the speed.
Then there are other and more advanced details:
Scripts - Heavy scripts that require long time to execute should be avoided.
Just making images smaller and reducing amount of them and amount of text per page can lead to a better experience.
What does Varnish cache do?
It is a web accelerator that allows websites to maintain very high traffic and load pages faster by caching HTML, Images, CSS, etc.
When a visitor visits your website first time, a copy of the site will be saved on a Varnish server. All next visitors will be served with this copy, which takes less time than getting it from the storage server. Therefore your website loads faster.
Varnish cache is something useful for e.g. web hosts and it might be activated by default. If a web host has support for .htaccess then every website owner can deactivate Varnish cache by simply using this code line:
Header add "Cache-Control" "no-cache"
Varnish cache is not always recommended. For example you should deactivate it if you update your website very often. Otherways some visitors can miss your updates and see wrong information. If you have opportunity to clear the Varnish cache then you do it after every new update so the new and fresh data can be published.
Remember that possible defects on the website can be stored in cache and that can appear annoying if the website does not work properly. Therefore we maybe should avoid Varnish cache if we are not so dependent on it.