haikuwebkit/Source/WebCore/loader/appcache
Ben Nham 01f723d687 Only cache GET requests in the memory cache
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
2021-06-10 19:02:51 +00:00
..
ApplicationCache.cpp
ApplicationCache.h
ApplicationCacheGroup.cpp Only cache GET requests in the memory cache 2021-06-10 19:02:51 +00:00
ApplicationCacheGroup.h
ApplicationCacheHost.cpp Use Vector<uint8_t> instead of Vector<char> to store bytes in SharedBuffer 2021-06-05 01:16:43 +00:00
ApplicationCacheHost.h Use Vector<uint8_t> instead of Vector<char> to store bytes in SharedBuffer 2021-06-05 01:16:43 +00:00
ApplicationCacheManifestParser.cpp Use `const uint8_t*` type more consistently to store bytes in WebKit 2021-06-06 05:25:41 +00:00
ApplicationCacheManifestParser.h Use `const uint8_t*` type more consistently to store bytes in WebKit 2021-06-06 05:25:41 +00:00
ApplicationCacheResource.cpp
ApplicationCacheResource.h
ApplicationCacheResourceLoader.cpp Use Vector<uint8_t> instead of Vector<char> to store bytes in SharedBuffer 2021-06-05 01:16:43 +00:00
ApplicationCacheResourceLoader.h Use Vector<uint8_t> instead of Vector<char> to store bytes in SharedBuffer 2021-06-05 01:16:43 +00:00
ApplicationCacheStorage.cpp Fix some inefficient uses of SharedBuffer 2021-06-10 15:08:18 +00:00
ApplicationCacheStorage.h Remove WTF::Optional synonym for std::optional, using that class template directly instead 2021-05-30 16:11:40 +00:00
DOMApplicationCache.cpp
DOMApplicationCache.h
DOMApplicationCache.idl [WebIDL] Remove the need to specify [MayThrowException] 2021-03-23 00:49:01 +00:00