Skip to content

Conversation

@moonmeister
Copy link
Member

  • Fix navs and index pages from prefetching tons of content when rendered to the screen
  • Fix Links from re-prefetching on every hover

@moonmeister moonmeister self-assigned this Jun 26, 2025
@moonmeister moonmeister added the bug Something isn't working label Jun 26, 2025
@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-fix-over-fetching https://hd…wered.com ✅ (logs)

Learn more about preview environments in our documentation.

@moonmeister moonmeister marked this pull request as ready for review June 30, 2025 19:37
@moonmeister moonmeister marked this pull request as draft June 30, 2025 19:38
@moonmeister
Copy link
Member Author

It seems Next link should be handling no re-prefetching...https://github.com/vercel/next.js/blob/canary/packages/next/src/client/link.tsx#L132-L187. I'm still unsure on why it's not working.

@moonmeister
Copy link
Member Author

Some more info: This is a Feature™️ of ISR. See: vercel/next.js#40268

TL;DR

The content "could have" changed in the background between hovers. In theory, these should return 304s and be relatively cheap.

On the WPE hosting, that theory breaks down 😮‍💨 More below.

Testing

In testing on localhost, I can reproduce this with minimal reproduction. Adding a revalidate time to a page's static props means it starts bypassing the deduplication. Note the valid cache-control headers

image

Problem

In theory, Cloudflare should cache these requests and respond with fresh content. See in the response below how CF only ever responds "Expired." The next server is registering a "HIT," but the CF cache isn't being refreshed. I'm not entirely sure why Next itself isn't responding with a 304, but it's not. Anyway, the issue here really seems to be incorrect cache headers.

My Realization

Well Then Homer

I had "No Cache" checked in dev tools. 🤦🏻 No, that's unchecked...304s are happening. The last remaining oddity is why no docs page other than /docs/ has a cache-header that matches its ISR config...all others are coming back as public, max-age=0, must-revalidate. Which isn't helping.

Okay, I'm confused. I'm seeing pages vary between public, max-age=0, must-revalidate and s-maxage=600, stale-while-revalidate=31535400. Gonna merge this as is as watch some things.

@moonmeister moonmeister marked this pull request as ready for review June 30, 2025 23:21
@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-fix-over-fetching https://hd…wered.com ✅ (logs)

Learn more about preview environments in our documentation.

@moonmeister moonmeister enabled auto-merge June 30, 2025 23:27
@moonmeister moonmeister requested review from a team June 30, 2025 23:28
@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-fix-over-fetching https://hd…wered.com ✅ (logs)

Learn more about preview environments in our documentation.

Copy link
Contributor

@Fran-A-Dev Fran-A-Dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@moonmeister moonmeister merged commit 9804586 into main Jul 1, 2025
4 checks passed
@moonmeister moonmeister deleted the fix-over-fetching branch July 1, 2025 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants