interception (Dynamic route) showing old/stale content
Unanswered
American Sable posted this in #help-forum
American SableOP
In my blog website, I have an interception route which shows the interception route (modal) before opening the actual article page, then when I refresh, the actual page is loaded, then after that there are article cards on that page too When I click (using Link tag of nextj14) on any one of the card, modal opens again and then I refreshes to see the actual article page.
Till now everything is working fine.
But notice that when I go back and forth the old data is shown, and it is not fetched every time, but if I delete the interception route folder from project, then I go back and forth, the new data is shown. why is this happening, why is it that after using interception modal, back and forth is not being fetched and old data is being shown.
Example->
currently on blog route ( localhost:300/blog) -> All the articles are visible here.
when I click on any one article say 'blog/article/slug-1', then firstly the modal pop-up opens, the I refresh then actual page of that article opens, url being the same 'blog/article/slug-1'.
Now I am on single article page where the data of that particular article is fetched and shown and other recommended article cards are also here.
Now when I click on any recommended article say 'blog/article/slug-2' (which has the same logic as above, like first modal, then actual page). Here my url is 'blog/article/slug-2'. Everything working fine till now.
The issue is that when I go back using browser back button the on the 'blog/article/slug-1' old data(recently fetched data of slug-2) is fixed and it is not changing as the dynamic route changes. Why is this so happening.
Till now everything is working fine.
But notice that when I go back and forth the old data is shown, and it is not fetched every time, but if I delete the interception route folder from project, then I go back and forth, the new data is shown. why is this happening, why is it that after using interception modal, back and forth is not being fetched and old data is being shown.
Example->
currently on blog route ( localhost:300/blog) -> All the articles are visible here.
when I click on any one article say 'blog/article/slug-1', then firstly the modal pop-up opens, the I refresh then actual page of that article opens, url being the same 'blog/article/slug-1'.
Now I am on single article page where the data of that particular article is fetched and shown and other recommended article cards are also here.
Now when I click on any recommended article say 'blog/article/slug-2' (which has the same logic as above, like first modal, then actual page). Here my url is 'blog/article/slug-2'. Everything working fine till now.
The issue is that when I go back using browser back button the on the 'blog/article/slug-1' old data(recently fetched data of slug-2) is fixed and it is not changing as the dynamic route changes. Why is this so happening.
1 Reply
American SableOP
Here is the simple and paraphrased version of my question for better understanding-> In my blog website, I have a feature where a modal pops up before opening an article. After refreshing the page, the actual article content is displayed. On the article page, there are also recommended article cards. When I click on a card, the modal appears again before showing the new article's content after a refresh.
Everything works as expected, but I noticed that when I navigate back and forth between articles, the old data is shown instead of fetching new data. However, if I remove the modal feature, the data updates correctly when navigating between articles. Why does the data not update when using the modal?
Everything works as expected, but I noticed that when I navigate back and forth between articles, the old data is shown instead of fetching new data. However, if I remove the modal feature, the data updates correctly when navigating between articles. Why does the data not update when using the modal?