diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-01-07 11:40:43 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-01-08 16:25:54 +0100 |
commit | a06f28ddb70cd1963076d6df2ef3716d45b7a13e (patch) | |
tree | 3a7f15ddd8ebb6d552e26005e1d8abc2c380e5fe /platform/default/online_file_source.cpp | |
parent | c5feadf0bd04d77335f56f79c1dea75a3c43c976 (diff) | |
download | qtlocation-mapboxgl-a06f28ddb70cd1963076d6df2ef3716d45b7a13e.tar.gz |
[core] only cache successful or NotFound responses
We don't want other types of error end up in our cache, since it'll likely evict perfectly good content.
Diffstat (limited to 'platform/default/online_file_source.cpp')
-rw-r--r-- | platform/default/online_file_source.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/platform/default/online_file_source.cpp b/platform/default/online_file_source.cpp index 37ac3e9838..120f21230c 100644 --- a/platform/default/online_file_source.cpp +++ b/platform/default/online_file_source.cpp @@ -276,7 +276,12 @@ void OnlineFileSource::Impl::startRealRequest(OnlineFileRequestImpl& request) { auto callback = [this, &request](std::shared_ptr<const Response> response) { request.realRequest = nullptr; - if (cache && !util::isAssetURL(request.resource.url)) { + // Only update the cache for successful or 404 responses. + // In particular, we don't want to write a Canceled request, or one that failed due to + // connection errors to the cache. Server errors are hopefully also temporary, so we're not + // caching them either. + if (cache && !util::isAssetURL(request.resource.url) && + (!response->error || (response->error->reason == Response::Error::Reason::NotFound))) { // Store response in database. Make sure we only refresh the expires column if the data // didn't change. FileCache::Hint hint = FileCache::Hint::Full; |