Cache implementation
So far, we have seen the theory part in this chapter. Let's try to implement the concept in our application. To simplify the cache implementation, we are going to use only user management. We will use the getUser
(single user) REST API to apply our caching concept.
The REST resource
In the getUser
method, we will pass the right userid
to the path variable, assuming the client will pass the userid
and get the resource. There are many caching options available to implement. Here, we will use only the If-Modified-Since
caching mechanism. As this mechanism will pass the If-Modified-Since
value in the header, it will be forwarded to the server, saying that, if the resource is changed after the specified time, get the resource fresh, or else return null.
There are many ways we can implement caching. As our goal is to simplify and convey the message clearly, we will keep the code simple, instead of adding complexity in the code. In order to implement this caching, we might need...