Skip to content

fix: set undefined ODB 404 TTLs to 60 seconds #1647

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

Merged
merged 7 commits into from
Oct 4, 2022
Merged

Conversation

orinokai
Copy link
Contributor

@orinokai orinokai commented Sep 30, 2022

Summary

This PR fixes a bug that causes 404 responses to be cached indefinitely by ODB functions, meaning that once an ODB route returns a 404 it can never be invalidated by a subsequent 200 response.

The bug occurred because Next Server sends standard cache control headers (SWR, max-age one year) for a 404 response, even if the URL is an ISR route which would otherwise (for a 200 response) send headers with a max age equal to the revalidate value. This means that our handler function was not adding a TTL to the builder function when an ISR page returned a 404.

Standard 404 pages on non-ISR routes will be routed to the standard non-ODB handler function and will therefore bypass the logic in this PR, which should only apply to ISR routes that conditionally return a notFound: true in getStaticProps.

Test plan

Visit /getStaticProps/with-revalidate-404/ on the demo site deploy preview and observe that the page should 404 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.

Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal

Closes netlify/pod-ecosystem-frameworks#246

cute fennec fox

@orinokai orinokai self-assigned this Sep 30, 2022
@netlify
Copy link

netlify bot commented Sep 30, 2022

Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!

Name Link
🔨 Latest commit 13585a4
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/633c2fb797ddba00092a103e
😎 Deploy Preview https://deploy-preview-1647--netlify-plugin-nextjs-static-root-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Sep 30, 2022

Deploy Preview for next-hp-edge-demo ready!

Name Link
🔨 Latest commit 13585a4
🔍 Latest deploy log https://app.netlify.com/sites/next-hp-edge-demo/deploys/633c2fb7a79dfc0008735339
😎 Deploy Preview https://deploy-preview-1647--next-hp-edge-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions bot added the type: bug code to address defects in shipped code label Sep 30, 2022
@netlify
Copy link

netlify bot commented Sep 30, 2022

Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!

Name Link
🔨 Latest commit 13585a4
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/633c2fb715869a0009809b63
😎 Deploy Preview https://deploy-preview-1647--netlify-plugin-nextjs-next-auth-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Sep 30, 2022

Deploy Preview for netlify-plugin-nextjs-export-demo ready!

Name Link
🔨 Latest commit 13585a4
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/633c2fb7ce936e0009d5a8d0
😎 Deploy Preview https://deploy-preview-1647--netlify-plugin-nextjs-export-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Sep 30, 2022

Deploy Preview for next-plugin-canary ready!

Name Link
🔨 Latest commit 13585a4
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/633c2fb774982b0009b7ae3f
😎 Deploy Preview https://deploy-preview-1647--next-plugin-canary.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Sep 30, 2022

Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!

Name Link
🔨 Latest commit 13585a4
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/633c2fb7802cb30008726f5e
😎 Deploy Preview https://deploy-preview-1647--netlify-plugin-nextjs-nx-monorepo-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Sep 30, 2022

Deploy Preview for next-i18next-demo ready!

Name Link
🔨 Latest commit 13585a4
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/633c2fb7295cd00009227348
😎 Deploy Preview https://deploy-preview-1647--next-i18next-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Sep 30, 2022

Deploy Preview for next-plugin-edge-middleware ready!

Name Link
🔨 Latest commit 13585a4
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/633c2fb71273cc0008a606b6
😎 Deploy Preview https://deploy-preview-1647--next-plugin-edge-middleware.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Sep 30, 2022

Deploy Preview for next-plugin-rsc-demo ready!

Name Link
🔨 Latest commit 13585a4
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-rsc-demo/deploys/633c2fb774982b0009b7ae3d
😎 Deploy Preview https://deploy-preview-1647--next-plugin-rsc-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Sep 30, 2022

Deploy Preview for nextjs-plugin-custom-routes-demo ready!

Name Link
🔨 Latest commit 13585a4
🔍 Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/633c2fb7ccd41d0008eadab8
😎 Deploy Preview https://deploy-preview-1647--nextjs-plugin-custom-routes-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Sep 30, 2022

Deploy Preview for netlify-plugin-nextjs-demo ready!

Name Link
🔨 Latest commit 13585a4
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/633c2fb797ddba00092a1038
😎 Deploy Preview https://deploy-preview-1647--netlify-plugin-nextjs-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@orinokai orinokai marked this pull request as ready for review October 3, 2022 18:03
@orinokai orinokai requested a review from a team October 3, 2022 18:03
Copy link
Contributor

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

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

Tried it and it works great!

@kodiakhq kodiakhq bot merged commit 029b497 into main Oct 4, 2022
@kodiakhq kodiakhq bot deleted the rs/fix-odb-404 branch October 4, 2022 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants