Skip to main content

Command Palette

Search for a command to run...

Caching for web Dev

Published
3 min read

What is Cache?

A cache -- pronounced CASH -- is hardware or software that is used to store something, usually data, temporarily in a computing environment. Cached data is stored temporarily in an accessible storage media(RAM) that's local to the cache client and separate from the main storage. The cache is commonly used by the central processing unit (CPU), applications, web browsers.

Why do we use Cache?

The cache is used because bulk or main storage can't keep up with the demands of clients. Cache decreases data access times, reduces latency and improves input/output (I/O). Because almost all application workloads depend on I/O operations, the caching process improves application performance

What are the benefits of Caches?

There are several benefits of caching, including the following:

  • Performance. Storing data in a cache allows a computer to run faster. For example, a browser cache that stores files from previous browsing sessions speed up access to follow-up sessions. A database cache speeds up data retrieval that would otherwise take a good bit of time and resources to download.

  • Offline work. Caches also let applications function without an internet connection. Application cache provides quick access to data that has been recently accessed or is frequently used. However, cache may not provide access to all application functions.

  • Resource efficiency. Besides speed and flexibility, caching helps physical devices conserve resources. For example, fast access to cache conserves battery power.

What is Brower Caching?

Before understanding the meaning of the term ‘browser caching’, it is important to know the concept of caching. Caching is a process in which data is kept in a cache. A cache is simply a storage area that stores data for a short time.

Browser caching is a process that involves the temporary storage of resources in web browsers. A visitor’s web browser downloads various website resources and stores them in the local drive. These include images, HTML files, and JavaScript files. When the user visits the website subsequently, the web page will load faster and the bandwidth usage will be reduced.

The Different Types of Browser Storage

  • Cookies

  • Local storage

  • Session storage

  • IndexedDB

  • Web SQL

  • Cache storage

Cache Storage

CacheStorage is a storage mechanism in browsers for storing and retrieving network requests and responses. It stores a pair of Request and Response objects, the Request as the key and Response as the value.

CacheStorage was created to enable websites to store network requests and responses, but it can also be used as a storage utility. For example, we can store custom data, like user preferences, in the cache, and they can be retrieved when required. The put method can be used to store the custom response objects in the cache storage.