DEV Community

loading...

Discussion on: Is just me or Gatsby is slow?

Collapse
patarapolw profile image
Pacharapol Withayasakpunt • Edited

I would love to see if SSG support incremental builds, especially from headless CMS's and WordPress API (and dev.to API).

This should be a solution to slow build times. Gosh, everyone knows that Android build time is much slower...

And your clients doesn't care about your slow build times, anyway.

Collapse
mjgs profile image
Mark Smith

How do incremental builds work?

If you are pulling data from APIs in building a static site are there certain types of APIs that handle incremental builds in a better way?

Collapse
patarapolw profile image
Pacharapol Withayasakpunt • Edited

An idea is updated timestamp.

Another idea is a SHA hash of JSON.stringify with sort keys.

But, I know no such API.

Thread Thread
mjgs profile image
Mark Smith

Yeah I was thinking that a hash of the content would be the easiest way to identify changes quickly, but how would APIs present this data?

Feels like a kind of complicated thing to implement, like file sync but for API data.

Thread Thread
mjgs profile image
Mark Smith

I did a bit more reading about this. I found this relevant stack overflow post.

It seems like there are a few approaches, but generally speaking record a last-modified timestamp and send this in an API response header, so clients only download data when new stuff has been added. I guess the API could also have a feature to only send back the new stuff when a last-modified timestamp is part of the request.

Worth considering these types of features imo when building APIs that are intended to be used in jamstack environments.

Thread Thread
rhymes profile image
rhymes

@patarapolw theoretically if the API supports proper HTTP caching it would work, the problem is that most generic HTTP libraries do not respect caching headers by default so it's a non starter :D

Thread Thread
mjgs profile image
Mark Smith

Not if you are building your own client :)
There is such a massive gain in terms of optimisation that it would become worthwhile quite quickly.