DEV Community

Cover image for HTTP CACHING
Freedisch
Freedisch

Posted on

HTTP CACHING

So, recently I decided to take a pause with programming and learn more about caching, proxies, and load balancers. I discovered a lot of stuff that I didn't know about. Therefore, today wanted to talk a bit about HTTP caching. It's something straightforward, and some don't know how it works.

WHAT IS CACHING
For who might not know what caching is?
It's like, a memory that saves your data from a request to reduce the time of access and resources. I think it will be much clear with a picture.

Image description

As we can see, our client sends a request to the server to read a file. Our server will send back a response to the client. It can be an HTML page or a JSON file, whatever.

Let's say after sometimes you decide to reread the same file or that you want to access the same data. What happens? Is your request going to be sent again to the server? And here is where caching comes from.

The caching protocol has already saved your data temporarily. So instead of the server sending you back the response, it will be your caching protocol that does the job for the server.

Image description

Image description

As you can see, it's no more the server who is sending the response but, The caching protocol. That process augments the speed of access time and reduces the network's usage.

There are multiple ways of configuring, but I'm going to talk about one that I find more exciting talk than others: E-tag. (if you want to know more about other ways of configuring HTTP caching, check out this article)

WHAT'S ETAG?

So, Etag is a unique identifier for a request. It helps the caching protocol to recognize if that request has already been sent or not, and if yes check if he has your data in the memory.

I heard that some people don't like it because it requires more configuration when you have more than 1 server and a load balancer. But I think it's not a big deal comparing his advantage, like the fact that it helps you prevent simultaneous updates of a resource from overwriting each other.

There is a lot to say about caching😁, so I wanted to make this article simple, hope it gives the feeling to dig more and learn more about caching.😊 Here is a great ressourceif you want to learn more.

I mentioned load balancers before, but I think it can also be a great subject to discuss next time.

I hope you enjoyed reading it! 😊 Let me know what you think about caching. Have you ever used it? What was your setup?

Thanks πŸ‘ŒπŸ˜Š

Top comments (0)