NEW staleTimes and router.back()
Unanswered
Bombay posted this in #help-forum
BombayOP
Nextjs finally added the feature everyone requested.
If you used a Link in the past even though it was dynamic the values got cache 30 sec.
In the new experimental feature you a specify this time yourself. For example to 0 (to disable the cache)
This all works pretty good and is awesome. But there is still one problem.
If you have two pages
1. list of data
2. detail page
On the first page you have links which point to the detail pages (for example list/:id)
On the second page you have a back button that executes router.back() that caches the previous page
Unfortunately staletime doesn’t work for router.back()
You could also use a link as a back button ( that would work and you always see up to date data.
But if you have set query params on page 1 through a filter for example you have no idea where to link back to.
In previous version you could do
router.back()
router.refresh()
on page 2, but this no longer works.
What would be a workaround without using
revalidatePath/tag
Help appreciated
If you used a Link in the past even though it was dynamic the values got cache 30 sec.
In the new experimental feature you a specify this time yourself. For example to 0 (to disable the cache)
This all works pretty good and is awesome. But there is still one problem.
If you have two pages
1. list of data
2. detail page
On the first page you have links which point to the detail pages (for example list/:id)
On the second page you have a back button that executes router.back() that caches the previous page
Unfortunately staletime doesn’t work for router.back()
You could also use a link as a back button ( that would work and you always see up to date data.
But if you have set query params on page 1 through a filter for example you have no idea where to link back to.
In previous version you could do
router.back()
router.refresh()
on page 2, but this no longer works.
What would be a workaround without using
revalidatePath/tag
Help appreciated