-
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
diffrent behaviors for browsers when page is restored from bfcache #44477
Comments
I have the same issue with the It causes the It seems that the working solution StackOverflow suggest is to add an empty unload listener to the body, so it refreshes the page. |
Setting 'unload' event listener means 'disable bfcache' also. I need bfcache spec, so setting unload event listener is not solution. |
@NamGungGeon isn't it wired that the nextjs showcases don't fall into bfcache issues even with the same version of browsers? Did you find any solution? |
Alternative solution I found is using deep-compare library(ex: https://www.npmjs.com/package/use-deep-compare) instead of Because router object is updated, but actually not changed inner values (router object inner values), so we can detect router is actually updated as comparing deeply router object. |
Hello, i am the one who having trouble with bfcache. few days ago, i got an answer from chatGPT that nextjs disable bfcache and in ssr evironment it is impossible to use bfcache because ssr render page and deliver browser. Chat GPT says that to use bfcache browser can get all the asset for page like behavior in an CSR environment. Since then, i see this issue today. following for invoking bug step, I tried to reproduce bfcache. but i cant. I thought a lot about this situation and i tried to follow the step not window os but mac os and then i could reproduce bfcache. I think how bfcache work might be the difference between OS. i comment for sharing. 안녕하세요. bfcache와 관련한 이슈 해결중에 있는 1인인데요. 얼마전에 chatGPT의 답변으로부터 ssr 환경에서는 bfcache 사용이 불가하고 nextjs는 bfcache를 disable 해놨다고 해서, 그런가보다 했는데 이 글을 마주치게 되었습니다. 들어가서 bfcache 재현 되도록 window환경에서 google 도메인에 이동했다가 뒤로가기를 했지만 bfcache로부터 복구가 안됐는데요. 원인이 무엇일까 생각하다가 mac으로 다시 확인해보니 100% 재현이 되네요.. 아마 chatGPT가 정확한 정보를 제공한건 아닌 것 같고, bfcache의 동작이 OS에도 달라지는 것 같아서, 공유 차원에서 댓글 드립니다. |
@NamGungGeon
|
Your code is calling handlePageShow() when pageshow event is triggered. That's irrelevant my issue. My issue demonstrates that |
I cloned your code and tested it, but my desktop chrome behaves differently. My test environment : window10/Chrome 113.0.5672.127 + MacOS Big Sur (11.6.8)/Chrome 113.0.5672.126 As for the difference between Safari and Chrome, I think the following link will help you. |
Verify canary release
Provide environment information
Which example does this report relate to?
using-router
What browser are you using? (if relevant)
desktop safari 16.1(18614.2.9.1.12), desktop chrome 108.0.5359.124(x86_64)
How are you deploying your application? (if relevant)
No response
Describe the Bug
Before describe...
I test it on next.js 12, 13, canary.
All version has same issue.
You can simply reproduce issue here. (https://why-router-is-updated.vercel.app/)
Summary of used code
Original code(used) is here
How to invoke bug
/?a=b
button./?a=b&c=d
button.www.google.com(Outer link)
button.useEffect(()=> {...}, [router])
is triggered.desktop chrome
desktop safari
- when page is restored from bfcache, router is updated. ( showed router update message alert)
What is problem?
Phase 7 is unexpected behavior.
(desktop/mobile safari and mobile chrome behavior is different from desktop chrome)
And also, in below situation, router is not updated on all browsers.
www.google.com(Outer link)
button.useEffect(()=> {...}, [router])
is not triggered.desktop chrome
desktop safari
- when page is restored from bfcache, router is not updated. (not showed router update message alert) - same as desktop chrome (also same as mobile chrome/safari)
Expected Behavior
When back button clicked from outer page(ex: google.com) and returned nextjs project pages, router must be updated or not updated on all browser. (do same behavior)
To Reproduce
Please see 'How to invoke bug' and 'What is problem' sections of
Describe the Bug
.If you cannot understanding my descriptions, please add comment.
Thanks for your efforts!
The text was updated successfully, but these errors were encountered: