diff --git a/.changeset/nasty-ladybugs-whisper.md b/.changeset/nasty-ladybugs-whisper.md new file mode 100644 index 0000000000000..d922187e5cb0e --- /dev/null +++ b/.changeset/nasty-ladybugs-whisper.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Prevents prefetching of the same urls with different hashes. diff --git a/packages/astro/src/prefetch/index.ts b/packages/astro/src/prefetch/index.ts index 177945f379a51..3eb8cd57018e3 100644 --- a/packages/astro/src/prefetch/index.ts +++ b/packages/astro/src/prefetch/index.ts @@ -215,6 +215,9 @@ export interface PrefetchOptions { * @param opts Additional options for prefetching. */ export function prefetch(url: string, opts?: PrefetchOptions) { + // Remove url hash to avoid prefetching the same URL multiple times + url = url.replace(/#.*/, ''); + const ignoreSlowConnection = opts?.ignoreSlowConnection ?? false; if (!canPrefetchUrl(url, ignoreSlowConnection)) return; prefetchedUrls.add(url);