Next.js Discord

Discord Forum

Nextjs Caching

Unanswered
Barbary Lion posted this in #help-forum
Open in Discord
Barbary LionOP
Hello, I have a history website http://history-maps.com/ using Nextjs 12.2.4 (not using 13 yet) and Firebase Firestore (version 8) as a data store. Recently, the traffic just doubled and my Firestore fees went up dramatically. While this is a nice problem to have, I would still like to know my options on how to reduce costs and I was hoping Nextjs caching can help. Note: due to the nature of my website, the data doesn't really change that much, apart from corrections and new updates. It's not like a news or ecommerce site.

1. I'm using getStaticProps revalidate option. At the moment, I am revalidating each day. If I up this to revalidate after one month, does that mean the data for the page the getStaticProps is in will cache the data for 1 month, so it won't hit the Firestore if the data has already been cached?
2. If I redeploy my app with a simple change, does it purge the whole cache and essentially start the cache all over again?
3. If I do redeploy, is this one way to update whatever data I may have changed?
4. is there any benefits to fetching the data using serverless functions?

Thanks for any guidance on this.

4 Replies

Barbary LionOP
4. server-side vs client-side data fetching.
how frequent is your data updated? you could build a page forever and only revalidate it when the source actually changes by using On-Demand Revalidation: https://nextjs.org/docs/pages/building-your-application/rendering/incremental-static-regeneration#on-demand-revalidation
Barbary LionOP
I update certain data from time to time, corrections, replacing better images, etc, but for the most part it doesn't change. It's a History website so unless I add something I missed when I added it, it's pretty much good. But I do update the app (not the data) with new experiements, features etc. I'll look into this on-demand revalidation. I've heard it before as an alternative to time revalidation. Thanks.