From dd357b5b84ed2cfbf75e296e24124095feaae7b3 Mon Sep 17 00:00:00 2001 From: Daniel Aleksandersen Date: Mon, 24 Dec 2018 23:42:45 +0100 Subject: [PATCH] Match Mozilla Necko's DNS cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Browsers cache TTL naïvely for 15 sec to 2 min. 12 hours is much too long. Serving stale content for up to half a day isn’t a great user experience. Match Firefox's DNS cache of 400 entries for up to 2 minutes. Mozilla experimented in 2018 with doubling their DNS cache from 400 to 800, but saw negligible improvements in cache hit ratios. https://bugzilla.mozilla.org/show_bug.cgi?id=1475781 --- add-on/src/lib/dnslink.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add-on/src/lib/dnslink.js b/add-on/src/lib/dnslink.js index 1c500852a..7ed2b7b37 100644 --- a/add-on/src/lib/dnslink.js +++ b/add-on/src/lib/dnslink.js @@ -9,7 +9,7 @@ const { pathAtHttpGateway } = require('./ipfs-path') module.exports = function createDnslinkResolver (getState) { // DNSLink lookup result cache - const cacheOptions = { max: 1000, maxAge: 1000 * 60 * 60 * 12 } + const cacheOptions = { max: 400, maxAge: 1000 * 60 * 2 } const cache = new LRU(cacheOptions) // upper bound for concurrent background lookups done by preloadDnslink(url) const lookupQueue = new PQueue({ concurrency: 8 })