Changeset 278717 in webkit
- Timestamp:
- Jun 10, 2021, 12:02:51 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r278713 r278717 1 2021-06-10 Ben Nham <nham@apple.com> 2 3 Only cache GET requests in the memory cache 4 https://bugs.webkit.org/show_bug.cgi?id=226359 5 6 Reviewed by Geoff Garen. 7 8 Added tests to make sure only GETs end up in the memory cache. 9 10 Also fixed a flaky test that was depending on a POST response in an iframe to be in the 11 memory cache when doing a history navigation. 12 13 * http/tests/cache/memory-cache-only-caches-get-expected.txt: Added. 14 * http/tests/cache/memory-cache-only-caches-get.html: Added. 15 * http/tests/cache/resources/echo-cacheable.cgi: Added. 16 * http/tests/navigation/post-frames-goback1.html: 17 * platform/mac/TestExpectations: 18 1 19 2021-06-10 Truitt Savell <tsavell@apple.com> 2 20 -
trunk/LayoutTests/http/tests/navigation/post-frames-goback1.html
r124692 r278717 9 9 testRunner.dumpBackForwardList(); 10 10 } 11 11 12 12 onload = function() 13 13 { … … 15 15 delete sessionStorage.didNav; 16 16 delete sessionStorage.topShouldNavAndGoBack; 17 if (window.testRunner) 18 testRunner.notifyDone(); 17 if (window.testRunner) { 18 // Wait until the iframe is showing the POST response before ending the test. 19 let el = document.getElementById('target-frame'); 20 if (el.src !== 'about:blank' && el.readyState === 'complete') { 21 testRunner.notifyDone(); 22 return; 23 } 24 25 el.onload = function() { 26 if (el.src !== 'about:blank') 27 testRunner.notifyDone(); 28 }; 29 } 19 30 } else { 20 31 sessionStorage.topShouldNavAndGoBack = true; … … 31 42 </form> 32 43 33 <iframe name="target-frame" src="about:blank"></iframe>44 <iframe id="target-frame" name="target-frame" src="about:blank"></iframe> 34 45 </body> 35 46 </html> -
trunk/LayoutTests/platform/mac/TestExpectations
r278629 r278717 807 807 # FIXME: Needs bugzilla (<rdar://problem/16040720>) 808 808 fast/canvas/canvas-scale-strokePath-shadow.html [ Pass Failure ] 809 810 # FIXME: Needs bugzilla (<rdar://problem/16663912>)811 # Seems like this should happen everywhere, but it only does on Yosemite.812 http/tests/navigation/post-frames-goback1.html [ Pass Failure ]813 809 814 810 # FIXME: Needs bugzilla (<rdar://problem/16802068>) -
trunk/Source/WebCore/ChangeLog
r278714 r278717 1 2021-06-10 Ben Nham <nham@apple.com> 2 3 Only cache GET requests in the memory cache 4 https://bugs.webkit.org/show_bug.cgi?id=226359 5 6 Reviewed by Geoff Garen. 7 8 Test: http/tests/cache/memory-cache-only-caches-get.html 9 10 We only cache GET requests at the disk cache level, but we don't have that same restriction 11 at the memory cache level. We should make the policies match. In particular, in long-running 12 webpages, we're accumulating POSTs from XMLHttpRequests in our memory cache and should stop 13 doing that, since POST response caching is generally not used or expected. 14 15 I also changed InspectorInstrumentation::willSendRequest to take an optional CachedResource 16 parameter because it currently uses InspectorPageAgent::cachedResource to find the resource, 17 which in turn expects to find the resource in the memory cache. That doesn't work anymore 18 for these non-GET requests, so we now pass down the CachedResource explicitly in the cases 19 where that's necessary. 20 21 * inspector/InspectorInstrumentation.cpp: 22 (WebCore::InspectorInstrumentation::willSendRequestImpl): 23 * inspector/InspectorInstrumentation.h: 24 (WebCore::InspectorInstrumentation::willSendRequest): 25 * inspector/agents/InspectorNetworkAgent.cpp: 26 (WebCore::resourceTypeForCachedResource): 27 (WebCore::InspectorNetworkAgent::willSendRequest): 28 * inspector/agents/InspectorNetworkAgent.h: 29 * loader/DocumentLoader.cpp: 30 (WebCore::DocumentLoader::tryLoadingSubstituteData): 31 (WebCore::DocumentLoader::addSubresourceLoader): 32 (WebCore::DocumentLoader::loadMainResource): 33 * loader/FrameLoader.cpp: 34 (WebCore::FrameLoader::requestFromDelegate): 35 * loader/ResourceLoadNotifier.cpp: 36 (WebCore::ResourceLoadNotifier::willSendRequest): 37 (WebCore::ResourceLoadNotifier::dispatchWillSendRequest): 38 * loader/ResourceLoadNotifier.h: 39 * loader/ResourceLoader.cpp: 40 (WebCore::ResourceLoader::willSendRequestInternal): 41 * loader/ResourceLoader.h: 42 (WebCore::ResourceLoader::cachedResource const): 43 * loader/SubresourceLoader.cpp: 44 * loader/SubresourceLoader.h: 45 * loader/appcache/ApplicationCacheGroup.cpp: 46 (WebCore::ApplicationCacheGroup::update): 47 (WebCore::ApplicationCacheGroup::startLoadingEntry): 48 * loader/cache/MemoryCache.cpp: 49 (WebCore::MemoryCache::add): 50 1 51 2021-06-10 Chris Dumez <cdumez@apple.com> 2 52 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r278516 r278717 573 573 } 574 574 575 void InspectorInstrumentation::willSendRequestImpl(InstrumentingAgents& instrumentingAgents, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse )576 { 577 if (auto* networkAgent = instrumentingAgents.enabledNetworkAgent()) 578 networkAgent->willSendRequest(identifier, loader, request, redirectResponse );575 void InspectorInstrumentation::willSendRequestImpl(InstrumentingAgents& instrumentingAgents, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse, const CachedResource* cachedResource) 576 { 577 if (auto* networkAgent = instrumentingAgents.enabledNetworkAgent()) 578 networkAgent->willSendRequest(identifier, loader, request, redirectResponse, cachedResource); 579 579 } 580 580 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r278516 r278717 194 194 static void applyEmulatedMedia(Frame&, String&); 195 195 196 static void willSendRequest(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse );196 static void willSendRequest(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse, const CachedResource*); 197 197 static void didLoadResourceFromMemoryCache(Page&, DocumentLoader*, CachedResource*); 198 198 static void didReceiveResourceResponse(Frame&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*); … … 419 419 static void applyEmulatedMediaImpl(InstrumentingAgents&, String&); 420 420 421 static void willSendRequestImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse );421 static void willSendRequestImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse, const CachedResource*); 422 422 static void willSendRequestOfTypeImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, LoadType); 423 423 static void markResourceAsCachedImpl(InstrumentingAgents&, unsigned long identifier); … … 1050 1050 } 1051 1051 1052 inline void InspectorInstrumentation::willSendRequest(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse )1053 { 1054 FAST_RETURN_IF_NO_FRONTENDS(void()); 1055 if (auto* agents = instrumentingAgents(frame)) 1056 willSendRequestImpl(*agents, identifier, loader, request, redirectResponse );1052 inline void InspectorInstrumentation::willSendRequest(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse, const CachedResource* cachedResource) 1053 { 1054 FAST_RETURN_IF_NO_FRONTENDS(void()); 1055 if (auto* agents = instrumentingAgents(frame)) 1056 willSendRequestImpl(*agents, identifier, loader, request, redirectResponse, cachedResource); 1057 1057 } 1058 1058 … … 1060 1060 { 1061 1061 FAST_RETURN_IF_NO_FRONTENDS(void()); 1062 willSendRequestImpl(instrumentingAgents(globalScope), identifier, nullptr, request, ResourceResponse { } );1062 willSendRequestImpl(instrumentingAgents(globalScope), identifier, nullptr, request, ResourceResponse { }, nullptr); 1063 1063 } 1064 1064 -
trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp
r278702 r278717 466 466 } 467 467 468 static InspectorPageAgent::ResourceType resourceTypeForCachedResource( CachedResource* resource)468 static InspectorPageAgent::ResourceType resourceTypeForCachedResource(const CachedResource* resource) 469 469 { 470 470 if (resource) … … 487 487 } 488 488 489 void InspectorNetworkAgent::willSendRequest(unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse) 490 { 491 auto* cachedResource = loader ? InspectorPageAgent::cachedResource(loader->frame(), request.url()) : nullptr; 489 void InspectorNetworkAgent::willSendRequest(unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse, const CachedResource* cachedResource) 490 { 491 if (!cachedResource && loader) 492 cachedResource = InspectorPageAgent::cachedResource(loader->frame(), request.url()); 492 493 willSendRequest(identifier, loader, request, redirectResponse, resourceTypeForCachedResource(cachedResource)); 493 494 } -
trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.h
r278516 r278717 99 99 void willRecalculateStyle(); 100 100 void didRecalculateStyle(); 101 void willSendRequest(unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse );101 void willSendRequest(unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse, const CachedResource*); 102 102 void willSendRequestOfType(unsigned long identifier, DocumentLoader*, ResourceRequest&, InspectorInstrumentation::LoadType); 103 103 void didReceiveResponse(unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*); -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r278702 r278717 748 748 m_identifierForLoadWithoutResourceLoader = m_frame->page()->progress().createUniqueIdentifier(); 749 749 frameLoader()->notifier().assignIdentifierToInitialRequest(m_identifierForLoadWithoutResourceLoader, this, m_request); 750 frameLoader()->notifier().dispatchWillSendRequest(this, m_identifierForLoadWithoutResourceLoader, m_request, ResourceResponse() );750 frameLoader()->notifier().dispatchWillSendRequest(this, m_identifierForLoadWithoutResourceLoader, m_request, ResourceResponse(), nullptr); 751 751 752 752 if (!m_deferMainResourceDataLoad || frameLoader()->loadsSynchronously()) … … 1846 1846 case Document::AboutToEnterBackForwardCache: { 1847 1847 // A page about to enter the BackForwardCache should only be able to start ping loads. 1848 auto* cachedResource = MemoryCache::singleton().resourceForRequest(loader->request(), loader->frameLoader()->frame().page()->sessionID());1848 auto* cachedResource = downcast<SubresourceLoader>(loader)->cachedResource(); 1849 1849 ASSERT(cachedResource && (CachedResource::shouldUsePingLoad(cachedResource->type()) || cachedResource->options().keepAlive)); 1850 1850 break; … … 2076 2076 m_identifierForLoadWithoutResourceLoader = m_frame->page()->progress().createUniqueIdentifier(); 2077 2077 frameLoader()->notifier().assignIdentifierToInitialRequest(m_identifierForLoadWithoutResourceLoader, this, mainResourceRequest.resourceRequest()); 2078 frameLoader()->notifier().dispatchWillSendRequest(this, m_identifierForLoadWithoutResourceLoader, mainResourceRequest.resourceRequest(), ResourceResponse() );2078 frameLoader()->notifier().dispatchWillSendRequest(this, m_identifierForLoadWithoutResourceLoader, mainResourceRequest.resourceRequest(), ResourceResponse(), nullptr); 2079 2079 } 2080 2080 -
trunk/Source/WebCore/loader/FrameLoader.cpp
r278391 r278717 3565 3565 3566 3566 ResourceRequest newRequest(request); 3567 notifier().dispatchWillSendRequest(m_documentLoader.get(), identifier, newRequest, ResourceResponse() );3567 notifier().dispatchWillSendRequest(m_documentLoader.get(), identifier, newRequest, ResourceResponse(), nullptr); 3568 3568 3569 3569 if (newRequest.isNull()) -
trunk/Source/WebCore/loader/ResourceLoadNotifier.cpp
r278516 r278717 66 66 m_frame.loader().applyUserAgentIfNeeded(clientRequest); 67 67 68 dispatchWillSendRequest(loader->documentLoader(), loader->identifier(), clientRequest, redirectResponse );68 dispatchWillSendRequest(loader->documentLoader(), loader->identifier(), clientRequest, redirectResponse, loader->cachedResource()); 69 69 } 70 70 … … 120 120 } 121 121 122 void ResourceLoadNotifier::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse )122 void ResourceLoadNotifier::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse, const CachedResource* cachedResource) 123 123 { 124 124 #if USE(QUICK_LOOK) … … 150 150 m_frame.loader().documentLoader()->didTellClientAboutLoad(request.url().string()); 151 151 152 InspectorInstrumentation::willSendRequest(&m_frame, identifier, loader, request, redirectResponse );152 InspectorInstrumentation::willSendRequest(&m_frame, identifier, loader, request, redirectResponse, cachedResource); 153 153 } 154 154 -
trunk/Source/WebCore/loader/ResourceLoadNotifier.h
r278516 r278717 36 36 37 37 class AuthenticationChallenge; 38 class CachedResource; 38 39 class DocumentLoader; 39 40 class Frame; … … 59 60 60 61 void assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&); 61 void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse );62 void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse, const CachedResource*); 62 63 void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&, ResourceLoader* = nullptr); 63 64 void dispatchDidReceiveData(DocumentLoader*, unsigned long identifier, const uint8_t* data, int dataLength, int encodedDataLength); -
trunk/Source/WebCore/loader/ResourceLoader.cpp
r278516 r278717 409 409 } 410 410 else 411 InspectorInstrumentation::willSendRequest(m_frame.get(), m_identifier, m_frame->loader().documentLoader(), request, redirectResponse );411 InspectorInstrumentation::willSendRequest(m_frame.get(), m_identifier, m_frame->loader().documentLoader(), request, redirectResponse, cachedResource()); 412 412 413 413 #if USE(QUICK_LOOK) -
trunk/Source/WebCore/loader/ResourceLoader.h
r278516 r278717 49 49 50 50 class AuthenticationChallenge; 51 class CachedResource; 51 52 class DocumentLoader; 52 53 class Frame; … … 131 132 WEBCORE_EXPORT bool isAllowedToAskUserForCredentials() const; 132 133 WEBCORE_EXPORT bool shouldIncludeCertificateInfo() const; 134 135 virtual CachedResource* cachedResource() const { return nullptr; } 133 136 134 137 bool reachedTerminalState() const { return m_reachedTerminalState; } -
trunk/Source/WebCore/loader/SubresourceLoader.cpp
r278516 r278717 153 153 #endif 154 154 155 CachedResource* SubresourceLoader::cachedResource()156 {157 return m_resource;158 }159 160 155 void SubresourceLoader::cancelIfNotFinishing() 161 156 { -
trunk/Source/WebCore/loader/SubresourceLoader.h
r278516 r278717 50 50 void cancelIfNotFinishing(); 51 51 bool isSubresourceLoader() const override; 52 CachedResource* cachedResource() ;52 CachedResource* cachedResource() const override { return m_resource; }; 53 53 WEBCORE_EXPORT const HTTPHeaderMap* originalHeaders() const; 54 54 -
trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp
r278702 r278717 439 439 440 440 m_currentResourceIdentifier = m_frame->page()->progress().createUniqueIdentifier(); 441 InspectorInstrumentation::willSendRequest(m_frame.get(), m_currentResourceIdentifier, m_frame->loader().documentLoader(), request, ResourceResponse { } );441 InspectorInstrumentation::willSendRequest(m_frame.get(), m_currentResourceIdentifier, m_frame->loader().documentLoader(), request, ResourceResponse { }, nullptr); 442 442 443 443 m_manifestLoader = ApplicationCacheResourceLoader::create(ApplicationCacheResource::Type::Manifest, documentLoader.cachedResourceLoader(), WTFMove(request), [this] (auto&& resourceOrError) { … … 900 900 901 901 m_currentResourceIdentifier = m_frame->page()->progress().createUniqueIdentifier(); 902 InspectorInstrumentation::willSendRequest(m_frame.get(), m_currentResourceIdentifier, m_frame->loader().documentLoader(), request, ResourceResponse { } );902 InspectorInstrumentation::willSendRequest(m_frame.get(), m_currentResourceIdentifier, m_frame->loader().documentLoader(), request, ResourceResponse { }, nullptr); 903 903 904 904 auto& documentLoader = *m_frame->loader().documentLoader(); -
trunk/Source/WebCore/loader/cache/MemoryCache.cpp
r278119 r278717 113 113 { 114 114 if (disabled()) 115 return false; 116 117 if (resource.resourceRequest().httpMethod() != "GET") 115 118 return false; 116 119
Note:
See TracChangeset
for help on using the changeset viewer.