Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Retrofit POST request cache

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

like image 236
Mitesh Vanaliya Avatar asked Aug 19 '16 13:08

Mitesh Vanaliya


People also ask

Does retrofit support caching?

Cache-control is a header used to specify caching policies in client requests and server responses. Note: You can only cache the GET requests.

What is Max age in cache-control?

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.

How does Okhttp cache work?

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.


1 Answers

OkHttp have support for file cache

like image 54
Alex Shutov Avatar answered Oct 18 '22 19:10

Alex Shutov