Skip to content

Astro's prefetch doesn't work in non-Chromium-based browsers #10464

@smastrom

Description

@smastrom

Astro Info

Astro                    v4.5.5
Node                     v21.6.1
System                   macOS (arm64)
Package Manager          pnpm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

Firefox, Safari

Describe the Bug

According to the docs, Astro prefetch should work on any browser whether or not View Transitions are enabled (as it is not mentioned otherwise).

I virtually tried any combination under my astro.config.mjs: prefetch: true, prefetch.prefetchAll: true, etc. And also to manually append the data-astro-prefetch attribute as explained in the docs and enable/disable ViewTransitions.

Under the "Network" tab of both Firefox 124 (latest) and Safari 17.4 (latest) there is no way I can see the incoming documents.

The only way to see them in that tab is to manually call prefetch() in a script tag using { with: 'fetch' }, however, those pages are then requested again to the server once I click on the correspondent links.

On Chrome and Edge (and I suppose any other Chromium-based browser) everything works as per docs.

I am not sure if this expected, if it's a bug or if I (hopefully) misinterpreted the docs and actually doing something wrong. Thank you.

What's the expected result?

To work on Firefox and Safari as it works on Chrome.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-astro-rdn9rn?file=src%2Flayouts%2FLayout.astro

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P4: importantViolate documented behavior or significantly impacts performance (priority)feat: prefetchRelated to the prefetch feature (scope)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions