Skip to content

Commit e38cacc

Browse files
craigsssmithnkzawa
authored andcommitted
Prevent prefetcher from making identical requests. (#665)
1 parent b78ab40 commit e38cacc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/prefetch.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,11 @@ export async function prefetch (href) {
121121
messenger.ensureInitialized()
122122

123123
const url = getPrefetchUrl(href)
124-
if (PREFETCHED_URLS[url]) return
124+
if (!PREFETCHED_URLS[url]) {
125+
PREFETCHED_URLS[url] = messenger.send({ action: 'ADD_URL', url: url })
126+
}
125127

126-
await messenger.send({ action: 'ADD_URL', url: url })
127-
PREFETCHED_URLS[url] = true
128+
return PREFETCHED_URLS[url]
128129
}
129130

130131
export async function reloadIfPrefetched (href) {

0 commit comments

Comments
 (0)