diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2020-02-13 11:56:13 +0200 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2020-02-14 11:54:02 +0200 |
commit | 89eab0530df08baf292d6d1260a3ae43019e3541 (patch) | |
tree | 29b0d82ca7ee3a68e275c3a3438ada2dbae48956 /platform | |
parent | 06f7951490982d777aae9f8144bfb8dcb508d234 (diff) | |
download | qtlocation-mapboxgl-89eab0530df08baf292d6d1260a3ae43019e3541.tar.gz |
[core] Set priorData from cache only if resource is useable
In cases when cached resource is useable, yet don't have an expiration
timestamp, we provided data to the requester from the cache and the same
data was returned once 304 response was received from the network.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/default/src/mbgl/storage/main_resource_loader.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/platform/default/src/mbgl/storage/main_resource_loader.cpp b/platform/default/src/mbgl/storage/main_resource_loader.cpp index 9bdf09fa10..aa8d745170 100644 --- a/platform/default/src/mbgl/storage/main_resource_loader.cpp +++ b/platform/default/src/mbgl/storage/main_resource_loader.cpp @@ -81,13 +81,17 @@ public: callback(response); // Set the priority of existing resource to low if it's expired but usable. res.setPriority(Resource::Priority::Low); + } else { + // Set prior data only if it was not returned to the requester. + // Once we get 304 response from the network, we will forward response + // to the requester. + res.priorData = response.data; } // Copy response fields for cache control request res.priorModified = response.modified; res.priorExpires = response.expires; res.priorEtag = response.etag; - res.priorData = response.data; } tasks[req] = requestFromNetwork(res, std::move(tasks[req])); |