-
Notifications
You must be signed in to change notification settings - Fork 26.1k
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
Using redirect
after revalidateTag()
, revalidatePath()
or cookies().set()
in server actions do not update the layouts or the back cache
#52075
Comments
The reproduction example provided uses I think it is important to note that the behaviour described in this issue and in the reproduction example has changed with This can be tested with a simple Master - Detail scenario: This was stated to be solved with below pull request in I thought this might be relevant for the person solving this issue. |
@schimi-dev what you're explaining is actually the correct behavior. For the case you're explaining where there is a list and an item, e.g. a blog overview and blog detail page, it's recommended to use const postId = 1
revalidateTag('blog-list')
revalidateTag(`blog-post-{postId}`) Or calling revalidatePath for both paths is fine too:
The one thing that is missing currently but we'll likely work on soon is setting tags based on the data in the request. E.g. being able to tag "this request returned these posts" then only |
@timneutkens sorry if I was unclear, i meant calling The general reproduction process:
Then the Master Page shows stale data. In my opinion, from how I understand the docs, the Master Page should not have stale data in that case. |
I created a reproduction repository for this: Here again the reproduction scenario and my thoughts on this topic:
Result: Then the Master Page shows stale data. In my opinion, from how I understand the docs, the Master Page should not have stale data. Using This example worked until From my (almost entirely blackbox-like) perspective there was a similar problem until Version Is it possible that this problem was unintentionally (re-)introduced by that pull request? |
I also had such a problem. It doesn't work with
It work without
|
@schimi-dev thanks, that's much clearer indeed, yeah that sounds like a bug, we'll have a look! |
Hello as of So i am going to close this issue. Thanks you @timneutkens for your job |
There are still some bugs :
Enregistrement.de.l.ecran.2023-08-01.a.03.10.42.movI updated the source code with the bug reproduction in this branch : https://github.com/Fredkiss3/next-redirect-cache-bug/tree/another-bug |
This comment was marked as spam.
This comment was marked as spam.
This issue only happens in edge runtime, And it does not depend wether I will close this and create a new one as this one is fixed. |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:19 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T8103 Binaries: Node: 18.16.0 npm: 9.5.1 Yarn: 1.22.19 pnpm: 8.6.2 Relevant Packages: next: 13.4.8-canary.14 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.6 Next.js Config: output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true)
Link to the code that reproduces this issue or a replay of the bug
https://github.com/Fredkiss3/next-redirect-cache-bug
To Reproduce
/
and click on either of the buttons, It will redirect you to/target
/target
with either the browser forward button or the link in the home page, and click on the linkGo home
, now you will see the home page with fresh data, but the layout will still show stale dataFor comparison :
/working
and and click on either of the buttons, you will see fresh data on the layout and the current pageGo to /target
, you will also see fresh dataEnregistrement.de.l.ecran.2023-07-01.a.14.57.07.mov
Describe the Bug
When using
redirect
after changing cookies or callingrevalidate
methods, next do not clear the browser back cache, so if the user navigates back to the previous page, they still see stale data, the layout data is also not refreshed and still shows stale data.If we dont' use
redirect
everything works as expected.This issue can be a problem because redirecting to login is common pattern after logging out a user (clearing the cookie associated with them).
Expected Behavior
The browser back cache should be cleared after a revalidation or modification of cookies, same for the layout stale data.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
NEXT-1414
The text was updated successfully, but these errors were encountered: