Skip to content

Commit

Permalink
Prevent prefetcher from making identical requests. (#665)
Browse files Browse the repository at this point in the history
  • Loading branch information
craigsssmith authored and nkzawa committed Jan 5, 2017
1 parent b78ab40 commit e38cacc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/prefetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e38cacc

Please sign in to comment.