CacheControl.FORCE_CACHEadds anonly-if-cacheflag and also sets the max-stale to a very high value which overrides the max-stale value.- The
max-agerequest directive indicates that the client is unwilling to accept a response whose age is greater than the specified number of seconds. Unless themax-stalerequest directive is also present, the client is not willing to accept a stale response. - The
max-stalerequest directive indicates that the client is willing to accept a response that has exceeded its freshness lifetime. If max-stale is assigned a value, then the client is willing to accept a response that has exceeded its freshness lifetime by no more than the specified number of seconds. - The
max-agerequest directive is the oldest that a response can be, as long as theCache-Controlfrom the origin server indicates that it is still fresh. Themax-stalerequest directive indicates that, even if the response is known to be stale, you will also accept it as long as it's only stale by that number of seconds. - A cache should generate a
Warningheader field with the110warn-code in stale responses. If you specifiedmax-staleand received ano-longer-freshresponse, theWarningheader would let you know.
####Resources
- https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
- https://en.wikipedia.org/wiki/List_of_HTTP_header_fields
- https://en.wikipedia.org/wiki/Web_cache#Cache_control
- https://newfivefour.com/android-retrofit2-okhttp3-cache-network-request-offline.html
- https://github.com/square/okhttp/wiki/Interceptors#rewriting-responses