How Caching Works.

Web Developer Kaustubh
2 min readMar 8, 2020

--

Photo by Thomas William on Unsplash

Caching

Web caching is the activity of storing data for reuse, such as a copy of a web page served by a web server.

It is cached or stored the first time a user visits the page and the next time a user requests the same page, a cache will serve the copy, which helps keep the origin server from getting overloaded.

Caching is storing something temporarily for fast retrieval later on.

What Can be Cached?

A]Logos and brand images

B]Style sheets

C]General Javascript files

D]Downloadable Content

E]Media Files

F]HTML pages etc

Locations Where Web Content Is Cached

Browser Cache:-

Browser caching allows your browser to store these files for a while, so it doesn’t need to retrieve them every time you visit the site.

Intermediary Caching Proxies:-

Any server between the client and your infrastructure.

Server Caching:-

Instead of processing every request, the server takes the results of these requests and stores them. It then serves these saved results instead.

Caching Headers

Expires: -

it sets a time in the future when the content will expire. At this point, any requests for the same content will have to go back to the origin server.

No-Cache:-

This instruction specifies that any cached content must be re-validated on each request before being served to a client.

No-Store:-

This instruction indicates that the content cannot be cached in any way.

Private:-

This marks the content as private. Private content may be stored by the user’s browser, but must not be cached by any intermediate parties.

Public:-

This marks the content as public, which means that it can be cached by the browser and any intermediate caches.

Max-Age:-

Specifies in seconds the amount of time the response will be cached. After the response has expired its deleted from the cache.

Must-Revalidate:-

It is an instruction that tells caches that once something becomes stale, it has to be checked on the origin server. If it isn’t present, caches can (generally) use stale responses in unusual circumstances.

Why use caching?

Fetching something over the network is both slow and expensive. Large responses require many roundtrips between the client and server, which require a lot of Delay loading data.

Web caching reduces the number of requests made to the server. Due to which less bandwidth is consumed and web server load is reduced.

--

--

Web Developer Kaustubh

Sr.Web developer. love to code. PHP , Javascript, Mysql, Laravel, Jquey, git, project planing,Linux