Changeset 252397 in webkit
- Timestamp:
- Nov 13, 2019 2:22:04 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 20 added
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r252391 r252397 1 2019-11-13 Rob Buis <rbuis@igalia.com> 2 3 Support stale-while-revalidate cache strategy 4 https://bugs.webkit.org/show_bug.cgi?id=201461 5 6 Reviewed by Youenn Fablet. 7 8 Skip newly imported tests for WK1. 9 10 * platform/ios-wk1/TestExpectations: 11 * platform/mac-wk1/TestExpectations: 12 1 13 2019-11-12 Fujii Hironori <Hironori.Fujii@sony.com> 2 14 -
trunk/LayoutTests/imported/w3c/ChangeLog
r252366 r252397 1 2019-11-13 Rob Buis <rbuis@igalia.com> 2 3 Support stale-while-revalidate cache strategy 4 https://bugs.webkit.org/show_bug.cgi?id=201461 5 6 Reviewed by Youenn Fablet. 7 8 Import stale-while-revalidate WPT tests. 9 10 * resources/import-expectations.json: 11 * web-platform-tests/fetch/stale-while-revalidate/fetch-expected.txt: Added. 12 * web-platform-tests/fetch/stale-while-revalidate/fetch-sw.https-expected.txt: Added. 13 * web-platform-tests/fetch/stale-while-revalidate/fetch-sw.https.html: Added. 14 * web-platform-tests/fetch/stale-while-revalidate/fetch.html: Added. 15 * web-platform-tests/fetch/stale-while-revalidate/resources/stale-css.py: Added. 16 (main): 17 * web-platform-tests/fetch/stale-while-revalidate/resources/stale-image.py: Added. 18 (main): 19 * web-platform-tests/fetch/stale-while-revalidate/resources/stale-script.py: Added. 20 (id_token): 21 (main): 22 * web-platform-tests/fetch/stale-while-revalidate/resources/w3c-import.log: Added. 23 * web-platform-tests/fetch/stale-while-revalidate/stale-css-expected.txt: Added. 24 * web-platform-tests/fetch/stale-while-revalidate/stale-css.html: Added. 25 * web-platform-tests/fetch/stale-while-revalidate/stale-image-expected.txt: Added. 26 * web-platform-tests/fetch/stale-while-revalidate/stale-image.html: Added. 27 * web-platform-tests/fetch/stale-while-revalidate/stale-script-expected.txt: Added. 28 * web-platform-tests/fetch/stale-while-revalidate/stale-script.html: Added. 29 * web-platform-tests/fetch/stale-while-revalidate/sw-intercept.js: Added. 30 (async.broadcast): 31 * web-platform-tests/fetch/stale-while-revalidate/w3c-import.log: Added. 32 1 33 2019-11-12 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 34 -
trunk/LayoutTests/imported/w3c/resources/import-expectations.json
r252335 r252397 177 177 "web-platform-tests/fetch/api/cors": "import", 178 178 "web-platform-tests/fetch/range": "import", 179 "web-platform-tests/fetch/stale-while-revalidate": "import", 179 180 "web-platform-tests/fullscreen": "skip", 180 181 "web-platform-tests/gamepad": "skip", -
trunk/LayoutTests/platform/ios-wk1/TestExpectations
r251279 r252397 2007 2007 # Skip IsLoggedIn 2008 2008 http/tests/is-logged-in/ [ Skip ] 2009 2010 # Stale-while-revalidate is not supported on WK1 2011 imported/w3c/web-platform-tests/fetch/stale-while-revalidate [ Skip ] -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r252353 r252397 823 823 824 824 webkit.org/b/203517 imported/w3c/web-platform-tests/css/css-sizing/dynamic-available-size-iframe.html [ Pass ImageOnlyFailure ] 825 826 # Stale-while-revalidate is not supported on WK1 827 imported/w3c/web-platform-tests/fetch/stale-while-revalidate [ Skip ] -
trunk/Source/WebCore/ChangeLog
r252393 r252397 1 2019-11-13 Rob Buis <rbuis@igalia.com> 2 3 Support stale-while-revalidate cache strategy 4 https://bugs.webkit.org/show_bug.cgi?id=201461 5 6 Reviewed by Youenn Fablet. 7 8 Start parsing the stale-while-revalidate Cache-Control directive 9 and expose it on ResourceResponse. 10 11 Tests: imported/w3c/web-platform-tests/fetch/stale-while-revalidate/fetch-sw.https.html 12 imported/w3c/web-platform-tests/fetch/stale-while-revalidate/fetch.html 13 imported/w3c/web-platform-tests/fetch/stale-while-revalidate/stale-css.html 14 imported/w3c/web-platform-tests/fetch/stale-while-revalidate/stale-image.html 15 imported/w3c/web-platform-tests/fetch/stale-while-revalidate/stale-script.html 16 17 * platform/network/CacheValidation.cpp: 18 (WebCore::parseCacheControlDirectives): 19 * platform/network/CacheValidation.h: 20 * platform/network/ResourceResponseBase.cpp: 21 (WebCore::ResourceResponseBase::cacheControlStaleWhileRevalidate const): 22 * platform/network/ResourceResponseBase.h: 23 1 24 2019-11-12 Simon Fraser <simon.fraser@apple.com> 2 25 -
trunk/Source/WebCore/platform/network/CacheValidation.cpp
r250153 r252397 314 314 if (ok) 315 315 result.maxStale = Seconds { maxStale }; 316 } else if (equalLettersIgnoringASCIICase(directives[i].first, "immutable")) 316 } else if (equalLettersIgnoringASCIICase(directives[i].first, "immutable")) { 317 317 result.immutable = true; 318 } else if (equalLettersIgnoringASCIICase(directives[i].first, "stale-while-revalidate")) { 319 if (result.staleWhileRevalidate) { 320 // First stale-while-revalidate directive wins if there are multiple ones. 321 continue; 322 } 323 bool ok; 324 double staleWhileRevalidate = directives[i].second.toDouble(&ok); 325 if (ok) 326 result.staleWhileRevalidate = Seconds { staleWhileRevalidate }; 327 } 318 328 } 319 329 } -
trunk/Source/WebCore/platform/network/CacheValidation.h
r250287 r252397 70 70 Markable<Seconds, Seconds::MarkableTraits> maxAge; 71 71 Markable<Seconds, Seconds::MarkableTraits> maxStale; 72 Markable<Seconds, Seconds::MarkableTraits> staleWhileRevalidate; 72 73 bool noCache : 1; 73 74 bool noStore : 1; -
trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp
r252047 r252397 658 658 } 659 659 660 Optional<Seconds> ResourceResponseBase::cacheControlStaleWhileRevalidate() const 661 { 662 if (!m_haveParsedCacheControlHeader) 663 parseCacheControlDirectives(); 664 return m_cacheControlDirectives.staleWhileRevalidate; 665 } 666 660 667 static Optional<WallTime> parseDateValueInHeader(const HTTPHeaderMap& headers, HTTPHeaderName headerName) 661 668 { -
trunk/Source/WebCore/platform/network/ResourceResponseBase.h
r252047 r252397 138 138 WEBCORE_EXPORT bool hasCacheValidatorFields() const; 139 139 WEBCORE_EXPORT Optional<Seconds> cacheControlMaxAge() const; 140 WEBCORE_EXPORT Optional<Seconds> cacheControlStaleWhileRevalidate() const; 140 141 WEBCORE_EXPORT Optional<WallTime> date() const; 141 142 WEBCORE_EXPORT Optional<Seconds> age() const; -
trunk/Source/WebKit/ChangeLog
r252392 r252397 1 2019-11-13 Rob Buis <rbuis@igalia.com> 2 3 Support stale-while-revalidate cache strategy 4 https://bugs.webkit.org/show_bug.cgi?id=201461 5 6 Reviewed by Youenn Fablet. 7 8 Add a new UseDecision value AsyncRevalidate for async revalidation. This is used 9 when the retrieved cache entry is a stale-while-revalidate response [1]. 10 In case of AsyncRevalidate, a check is made to see if there is a 11 current async revalidation ongoing for the entry, if not one is 12 started. Regardless, the stale entry is returned, until either the 13 async revalidation ends successfully or at the moment when the 14 response expires for real. 15 16 [1] https://fetch.spec.whatwg.org/#concept-stale-while-revalidate-response 17 18 * NetworkProcess/NetworkSession.cpp: 19 (WebKit::NetworkSession::NetworkSession): 20 * NetworkProcess/NetworkSession.h: 21 (WebKit::NetworkSession::isStaleWhileRevalidateEnabled const): 22 * NetworkProcess/NetworkSessionCreationParameters.cpp: 23 (WebKit::NetworkSessionCreationParameters::encode const): 24 (WebKit::NetworkSessionCreationParameters::decode): 25 * NetworkProcess/NetworkSessionCreationParameters.h: 26 * NetworkProcess/cache/AsyncRevalidation.cpp: Added. 27 (WebKit::NetworkCache::constructRevalidationRequest): 28 (WebKit::NetworkCache::AsyncRevalidation::staleWhileRevalidateEnding): 29 (WebKit::NetworkCache::AsyncRevalidation::AsyncRevalidation): 30 * NetworkProcess/cache/AsyncRevalidation.h: Added. 31 (WebKit::NetworkCache::AsyncRevalidation::load const): 32 * NetworkProcess/cache/NetworkCache.cpp: 33 (WebKit::NetworkCache::responseNeedsRevalidation): 34 (WebKit::NetworkCache::makeUseDecision): 35 (WebKit::NetworkCache::makeStoreDecision): 36 (WebKit::NetworkCache::Cache::startAsyncRevalidationIfNeeded): 37 (WebKit::NetworkCache::Cache::retrieve): 38 (WebKit::NetworkCache::responseHasExpired): Deleted. 39 * NetworkProcess/cache/NetworkCache.h: 40 * NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp: 41 (WebKit::NetworkCache::dumpHTTPHeadersDiff): 42 (WebKit::NetworkCache::requestsHeadersMatch): 43 * NetworkProcess/cache/NetworkCacheSpeculativeLoad.h: 44 * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp: 45 (WebKit::NetworkCache::dumpHTTPHeadersDiff): Deleted. 46 (WebKit::NetworkCache::requestsHeadersMatch): Deleted. 47 * Sources.txt: 48 * UIProcess/API/C/WKWebsiteDataStoreConfigurationRef.cpp: 49 (WKWebsiteDataStoreConfigurationGetStaleWhileRevalidateEnabled): 50 (WKWebsiteDataStoreConfigurationSetStaleWhileRevalidateEnabled): 51 * UIProcess/API/C/WKWebsiteDataStoreConfigurationRef.h: 52 * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: 53 (WebKit::WebsiteDataStore::parameters): 54 * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp: 55 (WebKit::WebsiteDataStoreConfiguration::copy const): 56 * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h: 57 (WebKit::WebsiteDataStoreConfiguration::staleWhileRevalidateEnabled const): 58 (WebKit::WebsiteDataStoreConfiguration::setStaleWhileRevalidateEnabled): 59 * WebKit.xcodeproj/project.pbxproj: 60 1 61 2019-11-12 Simon Fraser <simon.fraser@apple.com> 2 62 -
trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp
r251672 r252397 109 109 } 110 110 111 m_isStaleWhileRevalidateEnabled = parameters.staleWhileRevalidateEnabled; 112 111 113 m_adClickAttribution->setPingLoadFunction([this, weakThis = makeWeakPtr(this)](NetworkResourceLoadParameters&& loadParameters, CompletionHandler<void(const WebCore::ResourceError&, const WebCore::ResourceResponse&)>&& completionHandler) { 112 114 if (!weakThis) -
trunk/Source/WebKit/NetworkProcess/NetworkSession.h
r251672 r252397 125 125 unsigned testSpeedMultiplier() const { return m_testSpeedMultiplier; } 126 126 127 bool isStaleWhileRevalidateEnabled() const { return m_isStaleWhileRevalidateEnabled; } 128 127 129 protected: 128 130 NetworkSession(NetworkProcess&, const NetworkSessionCreationParameters&); … … 145 147 bool m_thirdPartyCookieBlockingEnabled { false }; 146 148 #endif 149 bool m_isStaleWhileRevalidateEnabled { false }; 147 150 UniqueRef<AdClickAttributionManager> m_adClickAttribution; 148 151 -
trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp
r251467 r252397 79 79 encoder << networkCacheSpeculativeValidationEnabled; 80 80 encoder << shouldUseTestingNetworkSession; 81 encoder << staleWhileRevalidateEnabled; 81 82 encoder << testSpeedMultiplier; 82 83 encoder << suppressesConnectionTerminationOnSystemChange; … … 244 245 if (!shouldUseTestingNetworkSession) 245 246 return WTF::nullopt; 246 247 248 Optional<bool> staleWhileRevalidateEnabled; 249 decoder >> staleWhileRevalidateEnabled; 250 if (!staleWhileRevalidateEnabled) 251 return WTF::nullopt; 252 247 253 Optional<unsigned> testSpeedMultiplier; 248 254 decoder >> testSpeedMultiplier; … … 293 299 , WTFMove(*networkCacheSpeculativeValidationEnabled) 294 300 , WTFMove(*shouldUseTestingNetworkSession) 301 , WTFMove(*staleWhileRevalidateEnabled) 295 302 , WTFMove(*testSpeedMultiplier) 296 303 , WTFMove(*suppressesConnectionTerminationOnSystemChange) -
trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h
r251467 r252397 97 97 bool networkCacheSpeculativeValidationEnabled { false }; 98 98 bool shouldUseTestingNetworkSession { false }; 99 bool staleWhileRevalidateEnabled { false }; 99 100 unsigned testSpeedMultiplier { 1 }; 100 101 bool suppressesConnectionTerminationOnSystemChange { false }; -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp
r250143 r252397 27 27 #include "NetworkCache.h" 28 28 29 #include "AsyncRevalidation.h" 29 30 #include "Logging.h" 31 #include "NetworkCacheSpeculativeLoad.h" 30 32 #include "NetworkCacheSpeculativeLoadManager.h" 31 33 #include "NetworkCacheStorage.h" 32 34 #include "NetworkProcess.h" 35 #include "NetworkSession.h" 33 36 #include <WebCore/CacheValidation.h> 34 37 #include <WebCore/HTTPHeaderNames.h> … … 153 156 } 154 157 155 static bool responseHasExpired(const WebCore::ResourceResponse& response, WallTime timestamp, Optional<Seconds> maxStale)158 static UseDecision responseNeedsRevalidation(NetworkSession& networkSession, const WebCore::ResourceResponse& response, WallTime timestamp, Optional<Seconds> maxStale) 156 159 { 157 160 if (response.cacheControlContainsNoCache()) 158 return true;161 return UseDecision::Validate; 159 162 160 163 auto age = WebCore::computeCurrentAge(response, timestamp); … … 163 166 auto maximumStaleness = maxStale ? maxStale.value() : 0_ms; 164 167 bool hasExpired = age - lifetime > maximumStaleness; 165 168 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 169 if (hasExpired && !maxStale && networkSession.isStaleWhileRevalidateEnabled()) { 170 auto responseMaxStaleness = response.cacheControlStaleWhileRevalidate(); 171 maximumStaleness += responseMaxStaleness ? responseMaxStaleness.value() : 0_ms; 172 bool inResponseStaleness = age - lifetime < maximumStaleness; 173 if (inResponseStaleness) 174 return UseDecision::AsyncRevalidate; 175 } 176 #endif 177 178 if (hasExpired) { 166 179 #ifndef LOG_DISABLED 167 if (hasExpired) 168 LOG(NetworkCache, "(NetworkProcess) needsRevalidation hasExpired age=%f lifetime=%f max-stale=%g", age, lifetime, maxStale); 169 #endif 170 171 return hasExpired; 172 } 173 174 static bool responseNeedsRevalidation(const WebCore::ResourceResponse& response, const WebCore::ResourceRequest& request, WallTime timestamp) 180 LOG(NetworkCache, "(NetworkProcess) needsRevalidation hasExpired age=%f lifetime=%f max-staleness=%f", age, lifetime, maximumStaleness); 181 #endif 182 return UseDecision::Validate; 183 } 184 185 return UseDecision::Use; 186 } 187 188 static UseDecision responseNeedsRevalidation(NetworkSession& networkSession, const WebCore::ResourceResponse& response, const WebCore::ResourceRequest& request, WallTime timestamp) 175 189 { 176 190 auto requestDirectives = WebCore::parseCacheControlDirectives(request.httpHeaderFields()); 177 191 if (requestDirectives.noCache) 178 return true;192 return UseDecision::Validate; 179 193 // For requests we ignore max-age values other than zero. 180 194 if (requestDirectives.maxAge && requestDirectives.maxAge.value() == 0_ms) 181 return true;182 183 return response HasExpired(response, timestamp, requestDirectives.maxStale);195 return UseDecision::Validate; 196 197 return responseNeedsRevalidation(networkSession, response, timestamp, requestDirectives.maxStale); 184 198 } 185 199 … … 198 212 return UseDecision::Use; 199 213 200 if (!responseNeedsRevalidation(entry.response(), request, entry.timeStamp())) 201 return UseDecision::Use; 214 auto decision = responseNeedsRevalidation(*networkProcess.networkSession(sessionID), entry.response(), request, entry.timeStamp()); 215 if (decision != UseDecision::Validate) 216 return decision; 202 217 203 218 if (!entry.response().hasCacheValidatorFields()) … … 252 267 if (!storeUnconditionallyForHistoryNavigation) { 253 268 auto now = WallTime::now(); 254 bool hasNonZeroLifetime = !response.cacheControlContainsNoCache() && WebCore::computeFreshnessLifetimeForHTTPFamily(response, now) > 0_ms; 255 269 Seconds allowedStale { 0_ms }; 270 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 271 if (auto value = response.cacheControlStaleWhileRevalidate()) 272 allowedStale = value.value(); 273 #endif 274 bool hasNonZeroLifetime = !response.cacheControlContainsNoCache() && (WebCore::computeFreshnessLifetimeForHTTPFamily(response, now) > 0_ms || allowedStale > 0_ms); 256 275 bool possiblyReusable = response.hasCacheValidatorFields() || hasNonZeroLifetime; 257 276 if (!possiblyReusable) … … 297 316 #endif 298 317 318 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 319 void Cache::startAsyncRevalidationIfNeeded(const WebCore::ResourceRequest& request, const NetworkCache::Key& key, std::unique_ptr<Entry>&& entry, const GlobalFrameID& frameID) 320 { 321 m_pendingAsyncRevalidations.ensure(key, [&] { 322 return makeUnique<AsyncRevalidation>(*this, frameID, request, WTFMove(entry), [this, key](AsyncRevalidation::Result result) { 323 m_pendingAsyncRevalidations.remove(key); 324 LOG(NetworkCache, "(NetworkProcess) Async revalidation completed for '%s' with result %d", key.identifier().utf8().data(), static_cast<int>(result)); 325 }); 326 }); 327 } 328 #endif 329 299 330 void Cache::retrieve(const WebCore::ResourceRequest& request, const GlobalFrameID& frameID, RetrieveCompletionHandler&& completionHandler) 300 331 { … … 335 366 #endif 336 367 337 m_storage->retrieve(storageKey, priority, [ request, completionHandler = WTFMove(completionHandler), info = WTFMove(info), storageKey, networkProcess = makeRef(networkProcess()), sessionID = m_sessionID](auto record, auto timings) mutable {368 m_storage->retrieve(storageKey, priority, [this, protectedThis = makeRef(*this), request, completionHandler = WTFMove(completionHandler), info = WTFMove(info), storageKey, networkProcess = makeRef(networkProcess()), sessionID = m_sessionID, frameID](auto record, auto timings) mutable { 338 369 info.storageTimings = timings; 339 370 340 371 if (!record) { 341 372 LOG(NetworkCache, "(NetworkProcess) not found in storage"); 342 343 373 completeRetrieve(WTFMove(completionHandler), nullptr, info); 344 374 return false; … … 351 381 auto useDecision = entry ? makeUseDecision(networkProcess, sessionID, *entry, request) : UseDecision::NoDueToDecodeFailure; 352 382 switch (useDecision) { 383 case UseDecision::AsyncRevalidate: { 384 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 385 auto entryCopy = makeUnique<Entry>(*entry); 386 entryCopy->setNeedsValidation(true); 387 startAsyncRevalidationIfNeeded(request, storageKey, WTFMove(entryCopy), frameID); 388 #endif 389 FALLTHROUGH; 390 } 353 391 case UseDecision::Use: 354 392 break; -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.h
r250287 r252397 51 51 namespace NetworkCache { 52 52 53 class AsyncRevalidation; 53 54 class Cache; 54 55 class SpeculativeLoadManager; … … 83 84 Use, 84 85 Validate, 86 AsyncRevalidate, 85 87 NoDueToVaryingHeaderMismatch, 86 88 NoDueToMissingValidatorFields, … … 168 170 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 169 171 SpeculativeLoadManager* speculativeLoadManager() { return m_speculativeLoadManager.get(); } 172 173 void startAsyncRevalidationIfNeeded(const WebCore::ResourceRequest&, const NetworkCache::Key&, std::unique_ptr<Entry>&&, const GlobalFrameID&); 170 174 #endif 171 175 … … 194 198 std::unique_ptr<WebCore::LowPowerModeNotifier> m_lowPowerModeNotifier; 195 199 std::unique_ptr<SpeculativeLoadManager> m_speculativeLoadManager; 200 201 HashMap<Key, std::unique_ptr<AsyncRevalidation>> m_pendingAsyncRevalidations; 196 202 #endif 197 203 -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp
r250053 r252397 156 156 } 157 157 158 #if !LOG_DISABLED 159 160 static void dumpHTTPHeadersDiff(const HTTPHeaderMap& headersA, const HTTPHeaderMap& headersB) 161 { 162 auto aEnd = headersA.end(); 163 for (auto it = headersA.begin(); it != aEnd; ++it) { 164 String valueB = headersB.get(it->key); 165 if (valueB.isNull()) 166 LOG(NetworkCacheSpeculativePreloading, "* '%s' HTTP header is only in first request (value: %s)", it->key.utf8().data(), it->value.utf8().data()); 167 else if (it->value != valueB) 168 LOG(NetworkCacheSpeculativePreloading, "* '%s' HTTP header differs in both requests: %s != %s", it->key.utf8().data(), it->value.utf8().data(), valueB.utf8().data()); 169 } 170 auto bEnd = headersB.end(); 171 for (auto it = headersB.begin(); it != bEnd; ++it) { 172 if (!headersA.contains(it->key)) 173 LOG(NetworkCacheSpeculativePreloading, "* '%s' HTTP header is only in second request (value: %s)", it->key.utf8().data(), it->value.utf8().data()); 174 } 175 } 176 177 #endif 178 179 bool requestsHeadersMatch(const ResourceRequest& speculativeValidationRequest, const ResourceRequest& actualRequest) 180 { 181 ASSERT(!actualRequest.isConditional()); 182 ResourceRequest speculativeRequest = speculativeValidationRequest; 183 speculativeRequest.makeUnconditional(); 184 185 if (speculativeRequest.httpHeaderFields() != actualRequest.httpHeaderFields()) { 186 LOG(NetworkCacheSpeculativePreloading, "Cannot reuse speculatively validated entry because HTTP headers used for validation do not match"); 187 #if !LOG_DISABLED 188 dumpHTTPHeadersDiff(speculativeRequest.httpHeaderFields(), actualRequest.httpHeaderFields()); 189 #endif 190 return false; 191 } 192 return true; 193 } 194 158 195 } // namespace NetworkCache 159 196 } // namespace WebKit -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.h
r250974 r252397 79 79 }; 80 80 81 bool requestsHeadersMatch(const WebCore::ResourceRequest& speculativeValidationRequest, const WebCore::ResourceRequest& actualRequest); 82 81 83 } // namespace NetworkCache 82 84 } // namespace WebKit -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp
r249501 r252397 257 257 } 258 258 259 #if !LOG_DISABLED260 261 static void dumpHTTPHeadersDiff(const HTTPHeaderMap& headersA, const HTTPHeaderMap& headersB)262 {263 auto aEnd = headersA.end();264 for (auto it = headersA.begin(); it != aEnd; ++it) {265 String valueB = headersB.get(it->key);266 if (valueB.isNull())267 LOG(NetworkCacheSpeculativePreloading, "* '%s' HTTP header is only in first request (value: %s)", it->key.utf8().data(), it->value.utf8().data());268 else if (it->value != valueB)269 LOG(NetworkCacheSpeculativePreloading, "* '%s' HTTP header differs in both requests: %s != %s", it->key.utf8().data(), it->value.utf8().data(), valueB.utf8().data());270 }271 auto bEnd = headersB.end();272 for (auto it = headersB.begin(); it != bEnd; ++it) {273 if (!headersA.contains(it->key))274 LOG(NetworkCacheSpeculativePreloading, "* '%s' HTTP header is only in second request (value: %s)", it->key.utf8().data(), it->value.utf8().data());275 }276 }277 278 #endif279 280 static bool requestsHeadersMatch(const ResourceRequest& speculativeValidationRequest, const ResourceRequest& actualRequest)281 {282 ASSERT(!actualRequest.isConditional());283 ResourceRequest speculativeRequest = speculativeValidationRequest;284 speculativeRequest.makeUnconditional();285 286 if (speculativeRequest.httpHeaderFields() != actualRequest.httpHeaderFields()) {287 LOG(NetworkCacheSpeculativePreloading, "Cannot reuse speculatively validated entry because HTTP headers used for validation do not match");288 #if !LOG_DISABLED289 dumpHTTPHeadersDiff(speculativeRequest.httpHeaderFields(), actualRequest.httpHeaderFields());290 #endif291 return false;292 }293 return true;294 }295 296 259 bool SpeculativeLoadManager::canUsePreloadedEntry(const PreloadedEntry& entry, const ResourceRequest& actualRequest) 297 260 { -
trunk/Source/WebKit/Sources.txt
r251814 r252397 79 79 NetworkProcess/cache/CacheStorageEngineCaches.cpp 80 80 NetworkProcess/cache/CacheStorageEngineConnection.cpp 81 NetworkProcess/cache/AsyncRevalidation.cpp 81 82 NetworkProcess/cache/NetworkCache.cpp 82 83 NetworkProcess/cache/NetworkCacheBlobStorage.cpp -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreConfigurationRef.cpp
r250463 r252397 140 140 WebKit::toImpl(configuration)->setTestingSessionEnabled(enabled); 141 141 } 142 143 bool WKWebsiteDataStoreConfigurationGetStaleWhileRevalidateEnabled(WKWebsiteDataStoreConfigurationRef configuration) 144 { 145 return WebKit::toImpl(configuration)->staleWhileRevalidateEnabled(); 146 } 147 148 void WKWebsiteDataStoreConfigurationSetStaleWhileRevalidateEnabled(WKWebsiteDataStoreConfigurationRef configuration, bool enabled) 149 { 150 WebKit::toImpl(configuration)->setStaleWhileRevalidateEnabled(enabled); 151 } -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreConfigurationRef.h
r250458 r252397 67 67 WK_EXPORT void WKWebsiteDataStoreConfigurationSetTestingSessionEnabled(WKWebsiteDataStoreConfigurationRef configuration, bool enabled); 68 68 69 WK_EXPORT bool WKWebsiteDataStoreConfigurationGetStaleWhileRevalidateEnabled(WKWebsiteDataStoreConfigurationRef configuration); 70 WK_EXPORT void WKWebsiteDataStoreConfigurationSetStaleWhileRevalidateEnabled(WKWebsiteDataStoreConfigurationRef configuration, bool enabled); 71 69 72 #ifdef __cplusplus 70 73 } -
trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
r251467 r252397 151 151 m_configuration->networkCacheSpeculativeValidationEnabled(), 152 152 m_configuration->testingSessionEnabled(), 153 m_configuration->staleWhileRevalidateEnabled(), 153 154 m_configuration->testSpeedMultiplier(), 154 155 m_configuration->suppressesConnectionTerminationOnSystemChange(), -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp
r252354 r252397 57 57 copy->m_fastServerTrustEvaluationEnabled = this->m_fastServerTrustEvaluationEnabled; 58 58 copy->m_networkCacheSpeculativeValidationEnabled = this->m_networkCacheSpeculativeValidationEnabled; 59 copy->m_staleWhileRevalidateEnabled = this->m_staleWhileRevalidateEnabled; 59 60 copy->m_cacheStorageDirectory = this->m_cacheStorageDirectory; 60 61 copy->m_perOriginStorageQuota = this->m_perOriginStorageQuota; -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h
r252354 r252397 85 85 bool testingSessionEnabled() const { return m_testingSessionEnabled; } 86 86 void setTestingSessionEnabled(bool enabled) { m_testingSessionEnabled = enabled; } 87 87 88 bool staleWhileRevalidateEnabled() const { return m_staleWhileRevalidateEnabled; } 89 void setStaleWhileRevalidateEnabled(bool enabled) { m_staleWhileRevalidateEnabled = enabled; } 90 88 91 unsigned testSpeedMultiplier() const { return m_testSpeedMultiplier; } 89 92 void setTestSpeedMultiplier(unsigned multiplier) { m_testSpeedMultiplier = multiplier; } 90 93 91 94 #if PLATFORM(COCOA) 92 95 CFDictionaryRef proxyConfiguration() const { return m_proxyConfiguration.get(); } … … 160 163 bool m_networkCacheSpeculativeValidationEnabled { false }; 161 164 #endif 165 bool m_staleWhileRevalidateEnabled { false }; 162 166 String m_localStorageDirectory; 163 167 String m_mediaKeysStorageDirectory; -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r252303 r252397 1396 1396 A7D792D81767CCA300881CBE /* ActivityAssertion.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D792D41767CB0900881CBE /* ActivityAssertion.h */; }; 1397 1397 AAB145E6223F931200E489D8 /* PrefetchCache.h in Headers */ = {isa = PBXBuildFile; fileRef = AAB145E4223F931200E489D8 /* PrefetchCache.h */; }; 1398 AAFA634F234F7C6400FFA864 /* AsyncRevalidation.h in Headers */ = {isa = PBXBuildFile; fileRef = AAFA634E234F7C6300FFA864 /* AsyncRevalidation.h */; }; 1398 1399 B62E7312143047B00069EC35 /* WKHitTestResult.h in Headers */ = {isa = PBXBuildFile; fileRef = B62E7311143047B00069EC35 /* WKHitTestResult.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1399 1400 B878B615133428DC006888E9 /* CorrectionPanel.h in Headers */ = {isa = PBXBuildFile; fileRef = B878B613133428DC006888E9 /* CorrectionPanel.h */; }; … … 4182 4183 AAB145E4223F931200E489D8 /* PrefetchCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrefetchCache.h; sourceTree = "<group>"; }; 4183 4184 AAB145E5223F931200E489D8 /* PrefetchCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrefetchCache.cpp; sourceTree = "<group>"; }; 4185 AAFA634E234F7C6300FFA864 /* AsyncRevalidation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncRevalidation.h; sourceTree = "<group>"; }; 4186 AAFA6350234F7C7300FFA864 /* AsyncRevalidation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AsyncRevalidation.cpp; sourceTree = "<group>"; }; 4184 4187 B396EA5512E0ED2D00F4FEB7 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; }; 4185 4188 B62E730F143047A60069EC35 /* WKHitTestResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKHitTestResult.cpp; sourceTree = "<group>"; }; … … 9218 9221 isa = PBXGroup; 9219 9222 children = ( 9223 AAFA6350234F7C7300FFA864 /* AsyncRevalidation.cpp */, 9224 AAFA634E234F7C6300FFA864 /* AsyncRevalidation.h */, 9220 9225 41897ED61F415D860016FA42 /* CacheStorageEngine.cpp */, 9221 9226 41897ED21F415D850016FA42 /* CacheStorageEngine.h */, … … 9466 9471 CE1A0BD21A48E6C60054EF74 /* AssertionServicesSPI.h in Headers */, 9467 9472 515E7728183DD6F60007203F /* AsyncRequest.h in Headers */, 9473 AAFA634F234F7C6400FFA864 /* AsyncRevalidation.h in Headers */, 9468 9474 BCEE966D112FAF57006BCC24 /* Attachment.h in Headers */, 9469 9475 E1A31732134CEA6C007C9A4F /* AttributedString.h in Headers */, -
trunk/Tools/ChangeLog
r252377 r252397 1 2019-11-13 Rob Buis <rbuis@igalia.com> 2 3 Support stale-while-revalidate cache strategy 4 https://bugs.webkit.org/show_bug.cgi?id=201461 5 6 Reviewed by Youenn Fablet. 7 8 Enable stale-while-revalidate for the test runner. 9 10 * WebKitTestRunner/TestController.cpp: 11 (WTR::TestController::websiteDataStore): 12 1 13 2019-11-12 Wenson Hsieh <wenson_hsieh@apple.com> 2 14 -
trunk/Tools/WebKitTestRunner/TestController.cpp
r252228 r252397 533 533 WKWebsiteDataStoreConfigurationSetPerOriginStorageQuota(configuration.get(), 400 * 1024); 534 534 WKWebsiteDataStoreConfigurationSetNetworkCacheSpeculativeValidationEnabled(configuration.get(), true); 535 WKWebsiteDataStoreConfigurationSetStaleWhileRevalidateEnabled(configuration.get(), true); 535 536 WKWebsiteDataStoreConfigurationSetTestingSessionEnabled(configuration.get(), true); 536 537 }
Note: See TracChangeset
for help on using the changeset viewer.