HTTP cache headers

In the HTTP protocol, there are a few cache mechanisms that can be used to indicate to a client that a page it's trying to fetch has not changed since their last visit. Caching is something we can do in our microservices on all the read-only API endpoints such as GETs and HEADs.

The simplest way to implement it is to return along with a result an ETag header in the response. An ETag value is a string that can be considered as a version for the resource the client is trying to get. It can be a timestamp, an incremental version, or a hash. It's up to the server to decide what to put in it. But the idea is that it should be unique to the value of the response.

Like web browsers, when the client fetches a response that contains ...

Get Python Microservices Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.