-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect if data is from cache #6
Comments
Can you use the cache's statistics reporting? |
I don't think so. Only that I will remember cache hit counter before request and compare it with state after request, if it will be incremented data are from cache, but I don't know if it is thread save, it would require same external synchronization which completely disallow parallel downloading :-( |
What's the issue with "local time precision"? I'm sure Android's clock resolution is very high (i.e. better than 1 millisecond), or if you mean that the user (or network) can change the value of |
I mean that user can have turned off automatic time synchronization and can have wrong system time. And my only solution that I found is compare current system time with time-stamp X-Android-Received-Millis. I can't use |
Craig and I are working hard to keep this version and the android version in sync! But the Android 4.0 code is complete and we can't add any new behavior there. |
When I repeat GET request before date defined in Expires header, HTTPUrlCoonection witch enabled cache doesn't make request to server, but return data directly from cache, but I don't found way how to detect this situation.
Only way that I found is
System.currentTimeMillis() - Long.parseLong(getResponseHeader("X-Android-Received-Millis")) > 100;
But this depends on local time precision.
Will be much better if in response will be same special header which allow to recognize data from cache.
But it is probably problem of original AOSP implementation :-(
The text was updated successfully, but these errors were encountered: