0

I've been reading about how nuxt can generate a static site when a client makes a request to view the website. We are planning to build a headless cms to migrate the database with the data the website needs. This data will only be changed when you save it in the headless cms.

My question is since this data will only change when it is changed in the headless cms. Isn't it possible to just generate the site when it is modified from the headless cms, and then serve that site to the client? To reduce server costs.

Is it possible to do this with nuxt? Or are there any possibilities to do this?

We are planning on using Firebase as a backend.

anonymous-dev
  • 2,897
  • 9
  • 48
  • 112

1 Answers1

0

There's nothing explicitly preventing Nuxt from being rebuilt each time you change an item in your DB. The part that matters is how you tell your app to rebuild itself.

By far the simplest way is using some sort of "build hook". See Netlifys docs here for a quick overview of what they are. However, this only really works if you're using a headless CMS that can send hooks on save, and a build provider that can trigger builds using those hooks.

You will absolutely save on server costs using this sort of method, but beware: if you have a lot of user generated content triggering builds, your build cost can easily outweigh the server costs. You also need to be aware that builds generally take a few minutes, so you won't see instant changes on your site.

The other option you have is foregoing static site generation in favour of SSR, which can dynamically load and render your content, completely avoiding the need to build every time a new DB change is made. This is what I'd consider the best alternative if you do indeed have a lot of user generated content.

It's hard to give any further advice without knowing the specifics of the CMS or build provider though.

HMilbradt
  • 3,980
  • 16
  • 31
  • But SSR renders the website for each client request right? – anonymous-dev Jul 16 '20 at 23:04
  • SSR renders the website for each request to the Nuxt server. However, you'd normally have some type of caching strategy in place to reduce the number of requests to the server. I would approach SSR with caution though, it can be a lot harder to develop on for a variety of reasons, and obviously has the downside that you need to maintain some kind of server. – HMilbradt Jul 16 '20 at 23:22