Skip to content
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

Consider caching fetch calls #21

Closed
alvarlagerlof opened this issue Jul 1, 2023 · 8 comments
Closed

Consider caching fetch calls #21

alvarlagerlof opened this issue Jul 1, 2023 · 8 comments

Comments

@alvarlagerlof
Copy link

image

I noticed these fetches happening in my Vercel dashboard and they seem to be mostly uncached. I wouldn't expect those files to change often. Is there a way that you / I can cache them?

@pomber
Copy link
Contributor

pomber commented Jul 13, 2023

just to check, you are using Bright on a dynamic page right?

@alvarlagerlof
Copy link
Author

It's not explicitly dynamic. It just has revalidate set.

@tom-sherman
Copy link

@alvarlagerlof if you change from a revalidate route config to instead setting revalidate on individual fetches then this problem should go away I think - those grammars and themes will be cached forever.

@alvarlagerlof
Copy link
Author

@alvarlagerlof if you change from a revalidate route config to instead setting revalidate on individual fetches then this problem should go away I think - those grammars and themes will be cached forever.

I don't trigger this fetch from my code. It's started by bright I think just by rendering the component on the server.

@tom-sherman
Copy link

Yes, but the default for Next.js will be to cache the fetch forever - if you have a revalidate route config then the grammars/themes will be refetched every time instead. You're telling Next.js to refetch in this instance.

This is why the Next.js docs recommend revalidating only the fetches you need instead of using the route segment config.

@alvarlagerlof
Copy link
Author

Yes, but the default for Next.js will be to cache the fetch forever - if you have a revalidate route config then the grammars/themes will be refetched every time instead. You're telling Next.js to refetch in this instance.

This is why the Next.js docs recommend revalidating only the fetches you need instead of using the route segment config.

Ah, my bad. I did misunderstand you. But now that I get your point, I remembered why it put it there. The main thing I want to have revalidating is a data fetch to sanity, using their JS package. I don't believe we have a way to control fetches like that yet right?

@tom-sherman
Copy link

Nope, not unless sanity allows you to pass the fetch options somehow (or swap out the fetch function entirely). It's the same issue as I just raised in lighter that's linked above.

@alvarlagerlof
Copy link
Author

Nope, not unless sanity allows you to pass the fetch options somehow (or swap out the fetch function entirely). It's the same issue as I just raised in lighter that's linked above.

Ah damn. I see. Your issue makes more sense (and on the right package, so I'll close this one).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants