Bug 1888815 - Do not set the NS_HTTP_REFRESH_DNS flag unless force-reloading the page r=necko-reviewers,jesup

This flag was previously being set for every page reload.
Only setting it for force-reload makes it so that we don't needlessly refresh
DNS cache entries and improves page load performance.

Differential Revision: https://phabricator.services.mozilla.com/D208141
This commit is contained in:
Valentin Gosu 2024-04-24 21:32:22 +00:00
Родитель 9e46b19a38
Коммит 622e7e0067
3 изменённых файлов: 15 добавлений и 4 удалений

Просмотреть файл

@ -12478,6 +12478,15 @@
value: 24
mirror: always
# This makes it so NS_HTTP_REFRESH_DNS is only
# set on DNS resolutions when LOAD_FRESH_CONNECTION is set.
# That's because we don't need to refresh DNS on
# every page reload.
- name: network.dns.only_refresh_on_fresh_connection
type: RelaxedAtomicBool
value: true
mirror: always
# The proxy type. See nsIProtocolProxyService.idl
# PROXYCONFIG_DIRECT = 0
# PROXYCONFIG_MANUAL = 1

Просмотреть файл

@ -6628,8 +6628,10 @@ nsresult nsHttpChannel::BeginConnect() {
Unused << gHttpHandler->AddConnectionHeader(&mRequestHead, mCaps);
if (!LoadIsTRRServiceChannel() &&
((mLoadFlags & LOAD_FRESH_CONNECTION) ||
(!StaticPrefs::network_dns_only_refresh_on_fresh_connection() &&
(mLoadFlags & VALIDATE_ALWAYS ||
BYPASS_LOCAL_CACHE(mLoadFlags, LoadPreferCacheLoadOverBypass()))) {
BYPASS_LOCAL_CACHE(mLoadFlags, LoadPreferCacheLoadOverBypass()))))) {
mCaps |= NS_HTTP_REFRESH_DNS;
}

Просмотреть файл

@ -316,7 +316,7 @@ add_task(async function testIPHintWithFreshDNS() {
);
let chan = makeChan(`https://test.iphint.org/server-timing`);
chan.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
chan.loadFlags |= Ci.nsIRequest.LOAD_FRESH_CONNECTION;
let [req] = await channelOpenPromise(
chan,
CL_EXPECT_FAILURE | CL_ALLOW_UNKNOWN_CL
@ -337,7 +337,7 @@ add_task(async function testIPHintWithFreshDNS() {
});
chan = makeChan(`https://test.iphint.org/server-timing`);
chan.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
chan.loadFlags |= Ci.nsIRequest.LOAD_FRESH_CONNECTION;
[req] = await channelOpenPromise(chan);
Assert.equal(req.protocolVersion, "h2");
let internal = req.QueryInterface(Ci.nsIHttpChannelInternal);