https://bugs.webkit.org/show_bug.cgi?id=226359
Reviewed by Geoff Garen.
Source/WebCore:
Test: http/tests/cache/memory-cache-only-caches-get.html
We only cache GET requests at the disk cache level, but we don't have that same restriction
at the memory cache level. We should make the policies match. In particular, in long-running
webpages, we're accumulating POSTs from XMLHttpRequests in our memory cache and should stop
doing that, since POST response caching is generally not used or expected.
I also changed InspectorInstrumentation::willSendRequest to take an optional CachedResource
parameter because it currently uses InspectorPageAgent::cachedResource to find the resource,
which in turn expects to find the resource in the memory cache. That doesn't work anymore
for these non-GET requests, so we now pass down the CachedResource explicitly in the cases
where that's necessary.
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::willSendRequestImpl):
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::willSendRequest):
* inspector/agents/InspectorNetworkAgent.cpp:
(WebCore::resourceTypeForCachedResource):
(WebCore::InspectorNetworkAgent::willSendRequest):
* inspector/agents/InspectorNetworkAgent.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::tryLoadingSubstituteData):
(WebCore::DocumentLoader::addSubresourceLoader):
(WebCore::DocumentLoader::loadMainResource):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::requestFromDelegate):
* loader/ResourceLoadNotifier.cpp:
(WebCore::ResourceLoadNotifier::willSendRequest):
(WebCore::ResourceLoadNotifier::dispatchWillSendRequest):
* loader/ResourceLoadNotifier.h:
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::willSendRequestInternal):
* loader/ResourceLoader.h:
(WebCore::ResourceLoader::cachedResource const):
* loader/SubresourceLoader.cpp:
* loader/SubresourceLoader.h:
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::update):
(WebCore::ApplicationCacheGroup::startLoadingEntry):
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::add):
LayoutTests:
Added tests to make sure only GETs end up in the memory cache.
Also fixed a flaky test that was depending on a POST response in an iframe to be in the
memory cache when doing a history navigation.
* http/tests/cache/memory-cache-only-caches-get-expected.txt: Added.
* http/tests/cache/memory-cache-only-caches-get.html: Added.
* http/tests/cache/resources/echo-cacheable.cgi: Added.
* http/tests/navigation/post-frames-goback1.html:
* platform/mac/TestExpectations:
Canonical link: https://commits.webkit.org/238685@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278717 268f45cc-cd09-0410-ab3c-d52691b4dbfc