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

swr routes throw 404 on consecutive requests + generated html is not cached #15084

Closed
warflash opened this issue Oct 3, 2022 · 6 comments
Closed

Comments

@warflash
Copy link
Member

warflash commented Oct 3, 2022

Environment


  • Operating System: Windows_NT
  • Node Version: v16.13.2
  • Nuxt Version: 3.0.0-rc.11
  • Nitro Version: -
  • Package Manager: npm@8.13.2
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/warflash/nuxt_swr
https://nuxt-swr.vercel.app/

Describe the bug

There's probably two distinct bugs here, not 100% sure. Can open another issue if required.

Deploying the above repro to vercel returns x-vercel-cache: MISS even after multiple refreshes, eventhough swr is enabled for all routes in the nuxt config. Additionally spam refreshing results in nuxt returning an error page This page is temporarily unavailable.

I have not tested this for different deploy targets so might be vercel related

Additional context

No response

Logs

No response

@warflash warflash changed the title swr routes throw 404 on consecutive requests + generated html is not cached (vercel) swr routes throw 404 on consecutive requests + generated html is not cached Oct 3, 2022
@danielroe danielroe added the nitro label Oct 4, 2022 — with Volta.net
@danielroe
Copy link
Member

Would you try again with rc12? We released a number of changes to nitro, including some changes to swr caching.

@warflash
Copy link
Member Author

Sure, updated the repro and live deployment to rc12. The 404 issue seems resolved from what I can tell, still no caching with swr -> x-vercel-cache: MISS. But that's expected I guess as unjs/nitro#545 is still pending

@danielroe
Copy link
Member

For caching on Vercel, you can set the following route rule:

'/**': { cache: { swr: true, maxAge: 120, staleMaxAge: 60, headersOnly: true } },

@Neuvier
Copy link

Neuvier commented Jan 12, 2023

On vercel, the swr cache is working when i refresh the app with F5, but not when i come from an internal nuxtlink where i still see external API calls ?

@danielroe
Copy link
Member

@Neuvier You will need to set experimental.payloadExtraction to enable extracting api calls.

@Neuvier
Copy link

Neuvier commented Jan 12, 2023

@Neuvier You will need to set experimental.payloadExtraction to enable extracting api calls.

It's working, Thanks so much !

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants