Page MenuHomePhabricator

Investigate the use of DNS prefetching for reducing page load time.
Closed, ResolvedPublic


Looking at (from, we can see a request that happens late and takes up 270ms. About 200ms of that seems to be the DNS lookup.

Modern browsers do DNS lookups in parallel while fetching the page content. They do this automatically for resources that are referenced from the content (e.g. it happens for bits & upload). However, isn't referenced anywhere in the page itself, as checkLoggedIn gets called from Javascript, which means that this DNS lookup gets serialized and blocked on that CentralAuth script getting fetched and evaluated.

This could be easily be parallelized and shave off a few ms by adding this to head:
<link rel="dns-prefetch" href="//">

@ori points out that could also be similarly prefetched, as it's used when running campaigns but not referenced anywhere in the original HTML.

There are possible other contenders that we should think of. Note that while major browsers perform link prefetching by default for link targets as well, it's disabled for privacy reasons when viewing a page over HTTPS, so we should explicitly prefetch cross-site links as well, within reason (i.e. not all Wikipedia language variants ;)).

Event Timeline

faidon raised the priority of this task from to Needs Triage.
faidon updated the task description. (Show Details)
faidon added subscribers: faidon, ori.
Aklapper triaged this task as Medium priority.Mar 17 2015, 12:53 PM
Krinkle added a subscriber: Krinkle.

CentralNotice added a dns-prefetch link for to the HTML in 2012 (7012f4e2b1d75; T42969).

CentralAuth could do this as well.

In general I would recommend we use preconnect rather than dns-prefetch, however. See for details.

Project tags change:

  • Removing Performance tag since this is not a performance-type problem, but rather an enhancement task for improving performance.
  • Moving away from MediaWiki tag since MediaWiki core already has support for adding such a link to the HTML (and has no further use for it by default).
  • Adding CentralNotice and CentralAuth for and respectively.

In general I would recommend we use preconnect rather than dns-prefetch, however. See for details.

preconnect might not be the best choice because CentralAuth only connects to at most once a day, using a value in localStorage to indicate when to check logged-in status again.

ori moved this task from Inbox to Doing (old) on the Performance-Team board.

Change 292985 had a related patch set uploaded (by Legoktm):
Prefetch $wgCentralAuthLoginWiki DNS

Change 292985 merged by jenkins-bot:
Prefetch $wgCentralAuthLoginWiki DNS

Change 293060 had a related patch set uploaded (by Ori.livneh):
Prefetch $wgCentralAuthLoginWiki DNS

Change 293060 merged by jenkins-bot:
Prefetch $wgCentralAuthLoginWiki DNS

Mentioned in SAL [2016-06-07T00:26:57Z] <ori@tin> Synchronized php-1.28.0-wmf.4/extensions/CentralAuth/includes/CentralAuthHooks.php: I79cbb1dc: Prefetch $wgCentralAuthLoginWiki DNS (T92864) (duration: 00m 29s)

We should make sure we dns-prefetch when lazy-loading images