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:
parent
b78ab40c9c
commit
e38cacc4c2
|
@ -121,10 +121,11 @@ export async function prefetch (href) {
|
||||||
messenger.ensureInitialized()
|
messenger.ensureInitialized()
|
||||||
|
|
||||||
const url = getPrefetchUrl(href)
|
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 })
|
return PREFETCHED_URLS[url]
|
||||||
PREFETCHED_URLS[url] = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function reloadIfPrefetched (href) {
|
export async function reloadIfPrefetched (href) {
|
||||||
|
|
Loading…
Reference in a new issue