summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-09-22 12:05:22 +0200
committerKonstantin Käfer <mail@kkaefer.com>2017-09-25 10:47:20 +0200
commitf281e6ae8a4f1e6d20a269a984d92dad9f49dcf2 (patch)
tree9a7d5ebe4194354d72cd351b242073d7da03eb55 /src/mbgl
parente556a57b7b196a9d8e9bb4af04ac88137b645688 (diff)
downloadqtlocation-mapboxgl-f281e6ae8a4f1e6d20a269a984d92dad9f49dcf2.tar.gz
[core] fix loading of stale must-revalidate resources
In https://github.com/mapbox/mapbox-gl-native/pull/9670, we implemented support for the Cache-Control: must-revalidate header. While we now respect this header and don't show resources that are stale and have this header set, the optional cache request never completes. This means we're also never going to try to actually get a fresh tile and just never show this tile anymore. This commit fixes this by responding with a Not Found error when the resource is unusable (= stale and has must-revalidate set). Since we actually still have the data (but can't use it due to caching rules), we're responding with the data as well. To avoid a second cache hit, tile_loader_impl.hpp now passes on the data from the Optional to the Required request so that it can be reused when we get a 304 Not Modified response from the server.
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/tile/tile_loader_impl.hpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/mbgl/tile/tile_loader_impl.hpp b/src/mbgl/tile/tile_loader_impl.hpp
index 899cbaf9b0..598ec32c10 100644
--- a/src/mbgl/tile/tile_loader_impl.hpp
+++ b/src/mbgl/tile/tile_loader_impl.hpp
@@ -61,7 +61,10 @@ void TileLoader<T>::loadOptional() {
// When the optional request could not be satisfied, don't treat it as an error.
// Instead, we make sure that the next request knows that there has been an optional
// request before by setting one of the prior* fields.
+ resource.priorModified = res.modified;
resource.priorExpires = Timestamp{ Seconds::zero() };
+ resource.priorEtag = res.etag;
+ resource.priorData = res.data;
} else {
loadedData(res);
}