CacheControl.FORCE_CACHE
adds anonly-if-cache
flag and also sets the max-stale to a very high value which overrides the max-stale value.- The
max-age
request directive indicates that the client is unwilling to accept a response whose age is greater than the specified number of seconds. Unless themax-stale
request directive is also present, the client is not willing to accept a stale response. - The
max-stale
request 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-age
request directive is the oldest that a response can be, as long as theCache-Control
from the origin server indicates that it is still fresh. Themax-stale
request 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
Warning
header field with the110
warn-code in stale responses. If you specifiedmax-stale
and received ano-longer-fresh
response, theWarning
header 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