The loaded page defines the heading Expires:Sat, 01 Jan 2000 00:00:00 GMT
, i.e. it is always considered obsolete and should always be re-selected.
Edit
Also returns Pragma: no-cache
. Basically, this says that your HTTP client never caches this page. You can remove these headers with the HttpResponseInterceptor if you are configured to cache the response.
# 2 Edit :
Using http-clientcache-4.2.jar
will be problematic, since it is not fully compatible with the version of the HTTP client packed with the Android SDK - you will get NoClassDefFoundError
and similar nonsense when using it.
However, if you “create your own” by downloading the source for clientcache-4.2 and deleting any broken links (for example, refactoring the package name to maintain a public log) and destroying all annotations sprinkled throughout the code (etc.), you can get a working version. If you do this, it worked:
class MakeCacheable implements HttpResponseInterceptor { public static MakeCacheable INSTANCE = new MakeCacheable(); public void process(HttpResponse resp, HttpContext ctx) throws HttpException, IOException { resp.removeHeaders("Expires"); resp.removeHeaders("Pragma"); resp.removeHeaders("Cache-Control"); } }
It is DefaultHttpClient
in the DefaultHttpClient
used by CachingHttpClient
as follows:
DefaultHttpClient realClient = new DefaultHttpClient(); realClient.addResponseInterceptor(MakeCacheable.INSTANCE, 0); // This goes first CachingHttpClient httpClient = new CachingHttpClient(realClient, cacheConfig);
If the record is cached or not, ResponseCachingPolicy
is determined, unfortunately, it is final
in the CachingHttpClient
, but when viewed through it, all the headers that need to be made to record without caching will be cached.