I want to know the concept difference
between warm cache
and cold cache
.
How do we use both these techniques effectively with varnish
and Redis cache
.
Any help, knowledge and experience sharing would be appreciated.
After waiting on this question, I gathered some of the concept of warm and cold cache.
By caching copies of image files, CSS, and HTML documents, the origin server does not have to generate these files each time a new visitor comes to the website. This both improves page load time and decreases stress on the origin server, meaning a website can serve more visitors at once.
Because modern websites are constantly being updated - whether it’s a media site updating the articles on their homepage or an ecommerce site updating inventory of a certain product - files are set to expire after a set period of time, which may be a minute or an hour. Each time a file in the cache expires, it needs to be re-collected from the origin server.
The first visitor to visit a website after a cache is initially set up or a cache expires will go through an empty or cold cache
and experience a cache miss
. The cache will visit the origin server to retrieve the file, deliver it to the visitor and keep the file in the cache so it is then a full or warm cache. Each subsequent user that visits before the cache expires again will be served from cache - a “cache hit” for all files that have been stored.
To summarize, a
cold cache
is one that does not have any files stored in it, and awarm cache
has files stored already and is prepared to serve visitors.
Warming a Varnish Cache
is a technique designed to shield users from this inconvenience by making those necessary but slow cache-refreshing requests yourself. You make a series of requests to your server for cacheable assets and you get the slow responses needed to refresh the cache instead of your users.
Redis
offers optional and tunable data persistence designed to bootstrap the cache after a planned shutdown or an unplanned failure. While we tend to regard the data in caches as volatile and transient, persisting data to disk can be quite valuable in caching scenarios. Having the cache’s data available for loading immediately after restart allows for much shorter cache warm-up
and removes the load involved in repopulating and recalculating cache contents from the primary data store.
I hope this will help others