getting data through pocket-base sdk
Answered
Scale parasitoid posted this in #help-forum
Scale parasitoidOP
is it cached like how nextjs caches its "fetch"? if not how do i force it to be only evaluated at build time.
It is somewhat cached, but if i refresh the browser 2 times or more, it busts the cache, and i can see pocketbase logging that nextjs indeed revalidated.
It is somewhat cached, but if i refresh the browser 2 times or more, it busts the cache, and i can see pocketbase logging that nextjs indeed revalidated.
Answered by Ray
it is not caching the result last time I tried so I have to wrap the function with
unstable_cache11 Replies
@Scale parasitoid is it cached like how nextjs caches its "fetch"? if not how do i force it to be only evaluated at build time.
It is somewhat cached, but if i refresh the browser 2 times or more, it busts the cache, and i can see pocketbase logging that nextjs indeed revalidated.
try passing the cache option to it
pb.collection("posts").getList(page, perPage, {
sort: "-created",
cache: "no-store",
})@Ray try passing the cache option to it
ts
pb.collection("posts").getList(page, perPage, {
sort: "-created",
cache: "no-store",
})
Scale parasitoidOP
hey thanks for replying! 🙂 but is it possible to mimic ssg in rsc? if i understood your suggestion correctly, vercel will still fetch to my pocketbase instance dynamically
@Scale parasitoid hey thanks for replying! 🙂 but is it possible to mimic ssg in rsc? if i understood your suggestion correctly, vercel will still fetch to my pocketbase instance dynamically
last time, I tried that it is the cache option from the fetch, it doesn't store the result to data cache
Scale parasitoidOP
i understand that using fetch will do this automatically, but alas, im too deep into the sdk before realizing this
the sdk use fetch under the hood
you could verfiy it by go to
.next/cache/fetch-cache@Ray the sdk use fetch under the hood
Scale parasitoidOP
yeah but i think nextjs hijacks fetch, but thanks i'll try your suggestion, thanks!
@Scale parasitoid yeah but i think nextjs hijacks fetch, but thanks i'll try your suggestion, thanks!
it is not caching the result last time I tried so I have to wrap the function with
unstable_cacheAnswer
@Ray it is not caching the result last time I tried so I have to wrap the function with `unstable_cache`
Scale parasitoidOP
it's working! thanks! i tried
cache from react earlier, wasnt aware that there's unstable_cache from next/cache. thanks Ray!@Scale parasitoid it's working! thanks! i tried `cache` from `react` earlier, wasnt aware that there's `unstable_cache` from `next/cache`. thanks Ray!
yeah, cache from react only live with the request