-
Notifications
You must be signed in to change notification settings - Fork 86
feat: cache redirects for 60 seconds if no ttl provided #1677
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
Conversation
✅ Deploy Preview for netlify-plugin-nextjs-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-export-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-plugin-edge-middleware ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-i18next-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-plugin-rsc-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-plugin-canary ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for nextjs-plugin-custom-routes-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
a7bf016
to
2fb25ea
Compare
f5f9cb7
to
2fb25ea
Compare
@orinokai, can we add an end to end test for this fix or is it not possible atm as we'd need to wait at least 60 seconds for it to invalidate? |
@nickytonline the main problem with adding a test is that the site won’t build when there is a redirect in |
Sounds good. I'll create an issue for it. |
Summary
Next.js uses 307 and 308 codes for its redirects, but our ODB functions currently only invalidate cached content for 200, 301 and 404 codes. This means ISR pages that conditionally return a redirect are not updating as expected.
A fix to Netlify Proxy for the above issue is currently in progress and this PR is a corresponding fix for a specific Next.js case: ISR pages with redirects, but without a
revalidate
value, are returned to the ODB with a defaultmax-age
of 1 year, which causes the ODB to cache them indefinitely. This PR ensures that redirects withoutrevalidate
are cached ephemerally for 60s.Test plan
Visit /getStaticProps/with-revalidate-redirect/ on the demo site deploy preview and observe that the page should redirect if the last digit of the current minute is 0-4 and should show a successful 200 response if the last digit is 5-9.Unable to create a test page in the default demo because redirect cannot be returned when pre-rendering. Tests to follow in a new demo site.
Relevant links (GitHub issues, Notion docs, etc.)
netlify/pillar-runtime#443
netlify/proxy#950