-
Notifications
You must be signed in to change notification settings - Fork 514
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
[vercel] support on-demand Incremental Static Invalidation (ISR) #1694
Comments
Wanted to add a couple of resources mentioned by Daniel R. during office hours. I am willing to try and work on this but I am not sure how far I can take it. https://github.com/unjs/nitro/blob/main/src/presets/vercel.ts |
I am trying to understand how nitro and the vercel preset work and
I found this resource that looks to be the better way to handle this: |
I am no vercel expert, but I think you can just add a dummy HEAD handler, then add a bypassToken in |
Yes @Hebilicious that seems to be correct. My question then is where should this bypassToken be set? Vercel recommends a randomized string during build time, however this would mean that you would have to update your webhook with every deploy. @pi0 would you or anyone else on the team have a recommendation for how this token is set? Vercel Env? |
Yeah surely you can radomize it via a vercel env variable so that it stays between build and also CI/CD to generate file with proper token. |
Wouldn't making the token randomized by deploy force the user to update their webhook headers every time? I was thinking the environment variable with the token would be set and used by the vercel preset as well as the webhook and therefore a single setup in a CMS would take care of this. |
Yes, i mean you can generate a randomized one and keep it vercel env (which is same across deploys). Although i think in regards of DX and cross platform support of cache invalidation, we might come up with something cleaner (like an encrypted password) and use it for vercel support via abstraction. |
@pi0 Then how would we start that process? Should I continue to focus on the vercel specific invalidation and then a new issue started to expand that or do I wait for the core team to provide some more details? |
You can directly go ahead with this feature in the meantime if like to help @hcmlopes Types should be updated here to add an option to enable vercel cache invalidation: https://github.com/unjs/nitro/blob/main/src/types/presets.ts#L9 Logic to auto generate Documentation about generating a secret and passing it to config via env, should go here: https://github.com/unjs/nitro/blob/main/docs/content/2.deploy/providers/vercel.md |
@pi0 I think I have the necessary code and documentation ready, however, as this is a preset change I am not sure how to go about testing. Would you be able to lend me a hand with this step? |
Feel free to draft a PR will help on next steps |
Describe the feature
Background
I think there is a need to support on-demand revalidation. In Vercel this could leverage the bypassToken field in the outputted
prerender-config.json
somehow.Naively I would think that Nitro can build some sort of a "protected route" - that uses a runtimeConfig key for auth - which when called, will ping the Vercel function with
x-prerender-revalidate: <bypassToken>
.Ideally this should be able to be done on a path level instead of the entire cache? (RFC)
Use Case
You can leverage the benefits of ISR and a long expiration, but if needed - an external service (e.g. CMS webhook) can ping your app at the nitro endpoint to revalidate the content. This will be useful for content that does not change too often, but crucial updates can be reliably made fast without caching issues or having to redeploy.
Additional information
The text was updated successfully, but these errors were encountered: