Bug 1816390 - Partition the cache entries generated by cross-origin fetch requests r=necko-reviewers,kershaw,jesup

Differential Revision: https://phabricator.services.mozilla.com/D195757
This commit is contained in:
Valentin Gosu 2024-01-16 09:22:16 +00:00
parent 8caf558610
commit fd4b32aa9e
2 changed files with 19 additions and 0 deletions

View file

@ -11429,6 +11429,13 @@
value: true
mirror: always
# If true, cross origin fetch (or XHR) requests would be keyed
# with a different cache key.
- name: network.fetch.cache_partition_cross_origin
type: RelaxedAtomicBool
value: true
mirror: always
# Whether to strip auth headers for redirected http channels
# https://fetch.spec.whatwg.org/#http-redirect-fetch
- name: network.http.redirect.stripAuthHeader

View file

@ -3762,6 +3762,18 @@ nsresult nsHttpChannel::OpenCacheEntryInternal(bool isHttps) {
if (mRequestHead.IsHead()) {
mCacheIdExtension.Append("HEAD");
}
bool isThirdParty = false;
if (StaticPrefs::network_fetch_cache_partition_cross_origin() &&
(NS_FAILED(mLoadInfo->TriggeringPrincipal()->IsThirdPartyChannel(
this, &isThirdParty)) ||
isThirdParty) &&
(mLoadInfo->InternalContentPolicyType() == nsIContentPolicy::TYPE_FETCH ||
mLoadInfo->InternalContentPolicyType() ==
nsIContentPolicy::TYPE_XMLHTTPREQUEST ||
mLoadInfo->InternalContentPolicyType() ==
nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST)) {
mCacheIdExtension.Append("FETCH");
}
mCacheOpenWithPriority = cacheEntryOpenFlags & nsICacheStorage::OPEN_PRIORITY;
mCacheQueueSizeWhenOpen =