1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Prevent prefetcher from making identical requests. (#665)

This commit is contained in:
Craig Smith 2017-01-05 10:16:20 +00:00 committed by Naoyuki Kanezawa
parent b78ab40c9c
commit e38cacc4c2

View file

@ -121,10 +121,11 @@ export async function prefetch (href) {
messenger.ensureInitialized()
const url = getPrefetchUrl(href)
if (PREFETCHED_URLS[url]) return
if (!PREFETCHED_URLS[url]) {
PREFETCHED_URLS[url] = messenger.send({ action: 'ADD_URL', url: url })
}
await messenger.send({ action: 'ADD_URL', url: url })
PREFETCHED_URLS[url] = true
return PREFETCHED_URLS[url]
}
export async function reloadIfPrefetched (href) {