next.js: ISR fails to serve 404 pages once the page gets deleted if experimental isr memory cache size is set to 0
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP Thu, 16 Jun 2022 13:32:35 +0000 Binaries: Node: 16.15.0 npm: 8.5.5 Yarn: 1.22.18 pnpm: N/A Relevant packages: next: 12.1.7-canary.45 react: 18.2.0 react-dom: 18.2.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
next start
Describe the Bug
Deleted ISR page shows old generated document even though it is already revalidated and should show 404 page.
This usually works as expected, but if you disable ISR memory cache (by setting isrMemoryCacheSize: 0
) it stops and always return the stale version of the page.
Expected Behavior
Deleted ISR page should return 404 page
Link to reproduction
https://github.com/pekarja5/next-isr-cache
To Reproduce
- Build and start the production build of provided repo.
- Navigate to
http://localhost:3000/detail/1
- In
public/detail.json
file, change the enabled parameter to 0 - After 5 seconds (revalidation period) refresh the page twice. First refresh should serve you the stale page while revalidating the page on server and the second should return 404 page, but it does not. Any later request will still serve the original stale version of the page never reaching the expected 404 page.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 23
- Comments: 16
Same issue on 13.0.3
This makes self hosting isr almost impossible in those cases when we want to remove pages and have shared static cache between instances.
Still present on 13.1.6.
I have done a workaround for this issue that might save someone else suffering from this issue: https://stackoverflow.com/questions/75731978/how-can-you-delete-statically-generated-nextjs-files-on-404-and-redirects
TLDR; - this is an implementation of how to delete the statically generated files yourself. The concept is for a single non-shared mount, so more exotic hosting setups might not be helped by this, but maybe.
I’ve made a workaround by passing a specific prop in the getStaticProps, and implementing a client-side redirect to the 404 page:
I know that solution is not ideal, because the page is still in the memory, but redirect is working and as we don’t pass other props, the size of next-data will be reduced.
Same issue here. Will this get fixed?