The current implementation is not aware of ETag at all, though it naturally stores ETag along with the rest of the headers. The CachedHTTPAdapter should be updated to add an If-None-Match to requests when the current cache entry is stale.
Note that the Cache interface is not sufficient for caches to implement time-based expiry, especially when combined with the desire to use the ETag to validate a stale entry. This is deliberate, as caches should not be altering requests, which is necessary with ETag. Instead, the adapter will check whether the CacheEntry returned by a cache is stale or not, and use the ETag if it is present.
Another option is to enhance the Cache interface. We could add a stale member to CacheEntry to indicate whether the entry is stale or not, as determined by the cache implementation. It would still be up to the adapter to make use of this information properly, and to delete any invalidated entries.
The current implementation is not aware of ETag at all, though it naturally stores ETag along with the rest of the headers. The
CachedHTTPAdapter
should be updated to add anIf-None-Match
to requests when the current cache entry is stale.Note that the
Cache
interface is not sufficient for caches to implement time-based expiry, especially when combined with the desire to use the ETag to validate a stale entry. This is deliberate, as caches should not be altering requests, which is necessary with ETag. Instead, the adapter will check whether theCacheEntry
returned by a cache is stale or not, and use the ETag if it is present.Another option is to enhance the
Cache
interface. We could add astale
member toCacheEntry
to indicate whether the entry is stale or not, as determined by the cache implementation. It would still be up to the adapter to make use of this information properly, and to delete any invalidated entries.