aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/android/volley/toolbox/DiskBasedCache.java
diff options
context:
space:
mode:
authorRalph Bergmann <ralph@the4thfloor.eu>2014-09-21 22:09:33 +0200
committerFicus Kirkpatrick <ficus@android.com>2015-02-15 09:09:05 -0800
commit9324df1b8046548587ffec89ec755264f6fbb097 (patch)
tree0f0cb0b835925767038340745b0faf82bce15996 /src/main/java/com/android/volley/toolbox/DiskBasedCache.java
parent3ac982d9455cb18d1c9ca10e695770d72fe21c90 (diff)
downloadvolley-9324df1b8046548587ffec89ec755264f6fbb097.tar.gz
Uses the "Last-Modified" header for "If-Modified-Since"
Uses the "Last-Modified" header for "If-Modified-Since" see http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.3.4 Change-Id: I0f5e9b45f4f79d7c1b286e465f9750dcd71b6bfd Signed-off-by: Ralph Bergmann <ralph@the4thfloor.eu>
Diffstat (limited to 'src/main/java/com/android/volley/toolbox/DiskBasedCache.java')
-rw-r--r--src/main/java/com/android/volley/toolbox/DiskBasedCache.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/com/android/volley/toolbox/DiskBasedCache.java b/src/main/java/com/android/volley/toolbox/DiskBasedCache.java
index b283788..036b55a 100644
--- a/src/main/java/com/android/volley/toolbox/DiskBasedCache.java
+++ b/src/main/java/com/android/volley/toolbox/DiskBasedCache.java
@@ -349,6 +349,9 @@ public class DiskBasedCache implements Cache {
/** Date of this response as reported by the server. */
public long serverDate;
+ /** The last modified date for the requested object. */
+ public long lastModified;
+
/** TTL for this record. */
public long ttl;
@@ -370,6 +373,7 @@ public class DiskBasedCache implements Cache {
this.size = entry.data.length;
this.etag = entry.etag;
this.serverDate = entry.serverDate;
+ this.lastModified = entry.lastModified;
this.ttl = entry.ttl;
this.softTtl = entry.softTtl;
this.responseHeaders = entry.responseHeaders;
@@ -396,6 +400,13 @@ public class DiskBasedCache implements Cache {
entry.ttl = readLong(is);
entry.softTtl = readLong(is);
entry.responseHeaders = readStringStringMap(is);
+
+ try {
+ entry.lastModified = readLong(is);
+ } catch (EOFException e) {
+ // the old cache entry format doesn't know lastModified
+ }
+
return entry;
}
@@ -407,6 +418,7 @@ public class DiskBasedCache implements Cache {
e.data = data;
e.etag = etag;
e.serverDate = serverDate;
+ e.lastModified = lastModified;
e.ttl = ttl;
e.softTtl = softTtl;
e.responseHeaders = responseHeaders;
@@ -426,6 +438,7 @@ public class DiskBasedCache implements Cache {
writeLong(os, ttl);
writeLong(os, softTtl);
writeStringStringMap(responseHeaders, os);
+ writeLong(os, lastModified);
os.flush();
return true;
} catch (IOException e) {