diff options
Diffstat (limited to 'include/mbgl/storage/response.hpp')
-rw-r--r-- | include/mbgl/storage/response.hpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/include/mbgl/storage/response.hpp b/include/mbgl/storage/response.hpp index 32fe4e0c8a..508400141b 100644 --- a/include/mbgl/storage/response.hpp +++ b/include/mbgl/storage/response.hpp @@ -2,7 +2,6 @@ #include <mbgl/util/chrono.hpp> #include <mbgl/util/optional.hpp> -#include <mbgl/util/variant.hpp> #include <string> #include <memory> @@ -27,6 +26,10 @@ public: // This is set to true for 304 Not Modified responses. bool notModified = false; + // This is set to true when the server requested that no expired resources be used by + // specifying "Cache-Control: must-revalidate". + bool mustRevalidate = false; + // The actual data of the response. Present only for non-error, non-notModified responses. std::shared_ptr<const std::string> data; @@ -37,6 +40,12 @@ public: bool isFresh() const { return expires ? *expires > util::now() : !error; } + + // Indicates whether we are allowed to use this response according to HTTP caching rules. + // It may or may not be stale. + bool isUsable() const { + return !mustRevalidate || (expires && *expires > util::now()); + } }; class Response::Error { |