Cache is showing old data on page navigations.
Unanswered
Gouty oak gall posted this in #help-forum
Gouty oak gallOP
I have a cache that I share between two pages, here is the code:
now, for some reason when i refresh the page, and then navigate to the previous page that also uses this cache, it shows a super old version of the data -- why is that? any help helps!
export const getRestaurant = cache(async (subdomain) => {
const item = await supabase.from('restaurant').select(`
*,
product (*, product_portions (*)),
menu_category (*)
`)
.eq('subdomain', subdomain).single()
console.log("ITEM:",item)
return item
})now, for some reason when i refresh the page, and then navigate to the previous page that also uses this cache, it shows a super old version of the data -- why is that? any help helps!
27 Replies
and what do you mean by "super old version"?
Gouty oak gallOP
yes, from react-- should i import from somewhere else, is there a next one?
"super old version" -- a version from weeks ago when i first started dev'ing (and im viewing it on dev server, not prod)
@Gouty oak gall yes, from react-- should i import from somewhere else, is there a next one?
no its fine, it is mainly used for deduplication
@Gouty oak gall "super old version" -- a version from weeks ago when i first started dev'ing (and im viewing it on dev server, not prod)
that's odd, can you show the code how you use it?
Gouty oak gallOP
yes
so i am defining it in my first page, and i call it here, on the same page
and then on the other page i import it
export default async function SubDomainPage({params}) {
const {data, error} = await getRestaurant(params.subdomain)and then on the other page i import it
export default async function ProductPage({params}) {
const {data} = await getRestaurant(params.subdomain)
const product = data.product.find(product => product.slug === params.id)do you think it coud be because i dont have the function in its own file?
no, it look fine. this is the way shown on their doc how to use it
does the problem occur every time you refresh and navigate back?
and does it show old data if you remove the
cache function?Gouty oak gallOP
yes, it does show old data when i remove the function
and it occurs every time
look like it maybe something wrong with other thing
Gouty oak gallOP
with supabase?
hmm, not sure. can you share the repo so I can have a look or test it?
Gouty oak gallOP
yes, can you share your gh username, it's private?
sweet
gonna share it and in the mean time test if it still does it when i put it in a api route and call it with fetch with the baked-in caching
ok let me check
@Gouty oak gall I have a cache that I share between two pages, here is the code:
js
export const getRestaurant = cache(async (subdomain) => {
const item = await supabase.from('restaurant').select(`
*,
product (*, product_portions (*)),
menu_category (*)
`)
.eq('subdomain', subdomain).single()
console.log("ITEM:",item)
return item
})
now, for some reason when i refresh the page, and then navigate to the previous page that also uses this cache, it shows a super old version of the data -- why is that? any help helps!
can you share more info about how to reproduce it?
first, go to [subdomain] page and refresh and then?
first, go to [subdomain] page and refresh and then?
Gouty oak gallOP
should i just dm you the supabase creds with the testing data?
sure that would be easier for me
Gouty oak gallOP
ok, sounds good
let me push and dm you
ok