Which is best way to store retrofit POST request cache ?
I will store response and using that response while user is offline. I was referred this link.
1) Can Retrofit with OKHttp use cache data when offline
2) Cache POST requests with OkHttp
But in this link cache mechanism work only GET method.
- It is possible to store cache in post request using retrofit ?
- Is any library to handle network cache?
Thanks
Cache-control is a header used to specify caching policies in client requests and server responses. Note: You can only cache the GET requests.
Cache-control: max-age It is the maximum amount of time specified in the number of seconds. For example, max-age=90 means that a HTTP response remains in the browser as a cached copy for the next 90 seconds before it can be available for reuse.
Basically: The client will send out something like timestamp or Etag of the last request. The server can then check if there is some data has changed in during that period of time or not. If nothing has changed, the server can just give a special code (304 -not modified) without sending the whole same response again.
OkHttp have support for file cache
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With