Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next.js apps send invalid Cache-Control headers #6492

Open
eatyourgreens opened this issue Nov 24, 2024 · 3 comments
Open

Next.js apps send invalid Cache-Control headers #6492

eatyourgreens opened this issue Nov 24, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@eatyourgreens
Copy link
Contributor

eatyourgreens commented Nov 24, 2024

Package

  • app-project
  • app-root

Describe the bug

Neither of the Next.js apps set a duration for stale-while-revalidate. This means that Incremental Static Regeneration (ISR) won’t work as expected.

Response headers for the Zooniverse homepage on an iPhone.

To Reproduce

Go to https://www.zooniverse.org, or any project page served by Next.js, and inspect the response headers.

Expected behavior

stale-while-revalidate must specify a duration in seconds. See the MDN page for Cache-Control.


Cache-Control: max-age=604800, stale-while-revalidate=86400

Additional context

This is a very old bug in Next.js, fixed in vercel/next.js#61330

Vercel deployments work without the duration, but that's a non-standard feature specific to Vercel. CDNs like CloudFront support the standard. I don't know what support is like in Azure FrontDoor.

@eatyourgreens eatyourgreens added the bug Something isn't working label Nov 24, 2024
@eatyourgreens
Copy link
Contributor Author

eatyourgreens commented Nov 24, 2024

I think Zooniverse is running quite an old version of Next.js, so probably needs to manually set swrDelta in the Next.js config. There have been a few bug fix releases since 14.2.7, including changes to how the duration is set for ISR revalidation.

I also think recent versions of Next.js set the revalidation time to one year by default.

More recently, the config key was renamed to expireTime.

@eatyourgreens
Copy link
Contributor Author

eatyourgreens commented Nov 24, 2024

This is from 2022, so might be outdated now, but says that Azure Front Door doesn't support stale-while-revalidate.

However, the related feature request is marked as completed.

Nginx might be the answer, in order to use ISR while self-hosting with AFD.

We'd also really like to see this in Front Door. Currently, we deploy an additional NGINX into our app service via Docker Compose to facilitate stale-while-revalidate for server-side rendered pages of our Next.js application.

@goplayoutside3
Copy link
Contributor

Agreed. This will be addressed when upgrading Next 14 --> Next 15.

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

No branches or pull requests

2 participants