Cache is temporarily stored data. This is a general concept, and I think this is why many developers struggle with it a lot.
Because Cache is temporary data, we should think where and how long to store the data.
There are several locations where we can save cache data. The most common place is the browser in a client. Not only client sides but also server sides (origin servers) can hold a cache. Other examples are CDN, load-balancers, etc….
There are several purposes for using Cache.
Basically, Cache reduce requests to
Cache is just temporary data, so it can be stored in any storage. In RAM, SSD, HDD, and so on. In this post, I call Cache in means of “HTTP cache”.
HTTP Headers Cache-Control
can control HTTP cache.
Both requests and responses can contain these headers.
Mozilla developer documents: https://developer.mozilla.org/de/docs/Web/HTTP/Headers/Cache-Control
Cache-Control: max-age=<seconds>
Cache-Control: max-stale[=<seconds>]
Cache-Control: min-fresh=<seconds>
Cache-Control: no-cache
Cache-Control: no-store
Cache-Control: no-transform
Cache-Control: only-if-cached
Cache-Control: must-revalidate
Cache-Control: no-cache
Cache-Control: no-store
Cache-Control: no-transform
Cache-Control: public
Cache-Control: private
Cache-Control: proxy-revalidate
Cache-Control: max-age=<seconds>
Cache-Control: s-maxage=<seconds>