Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Explanation of caching and ETAG? #678
Is there a proper explanation on how to add caching and ETAG/If-None-Match support to Retrofit+OkHttp?
Following are my attempts to make it work. Results show that caching seems to be working within the same instance of the application, but as soon as I restart - everything loads long again.
Here are some code samples:
Rest adapter is then created with FULL log level and a custom tag:
I have a long request on the first screen of the app for testing.
Retrofit has nothing to do with caching so there's nothing to talk about there. OkHttp just implements RFC 2616 caching which is the spec for HTTP. Not all of the flags are implemented, but most are. Ensure you are using the latest version of OkHttp (2.2.0) to be sure.
I found this article to be a good summary of how cache header values work: http://www.mobify.com/blog/beginners-guide-to-http-cache-headers/. If you server is sending proper cache headers this should just work. If you aren't seeing proper behavior then please file an issue on OkHttp with the response headers from the server, the expected behavior, and the observed behavior.
Retrofit is just an HTTP client consumer so it's 100% agnostic and opaque to any caching strategy implemented by that client.