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.
@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
I'd love to see a benchmark on the build times across static site generators. Definitely a worthy head-to-head comparison. Not a lot of other features are quite as quantifiable.
We ran two tests to measure build times with Hugo and Jekyll. The basic test used the default installation of Jekyll and Hugo to build sites with 10 posts,100 posts, 1,000 posts and 10,000 posts. The advanced test built those same sites but included common plugins and template code in order to create a similar set of features between the two Static Site Generators. For each build, Hugo proved to be between 23 and 63 times faster than Jekyll!
Brian Rinaldi is a Developer Experience Engineer at LaunchDarkly with over 20 years experience as a developer for the web. Brian is active in the community running CFE.dev and Orlando Devs.
Personally, yes, I agree. In fact, Jekyll used to be criticized for this but has made enormous improvements in this area. I tend to favor Hugo partly for this reason - it is blazing fast. The fact that it is written in Go, shouldn't be a concern for most folks as all you need to learn is the templating - and you can still use your frontend framework if you want.
Fact. I've tried 11ty too. I'll second that. I haven't tried Hugo but they say it's build time is faster than any other SSG... With Gatsby I even feel like it's slowing my computer too...
I am a polyglot seasoned software engineer. Besides the day job, I contribute to open source projects, beta test startup products, and offer consultancy.
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.
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?
An idea is updated timestamp.
Another idea is a SHA hash of JSON.stringify with sort keys.
But, I know no such API.
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.
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.
@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
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.
I'd love to see a benchmark on the build times across static site generators. Definitely a worthy head-to-head comparison. Not a lot of other features are quite as quantifiable.
Just found out there are 460 static site generators so it's probably a job in itself to write a benchmark :D
The only benchmark I'm aware of is Hugo vs Jekyll: Benchmarked:
The article also refers to Smashing Magazine having switched from Wordpress to Hugo + Netlify with build times of 13 seconds for 7500 pages.
Hugo itself shows the following video on its homepage in which they build a 5000 pages blog in 6 seconds:
This is so amazing... Man, 5k pages in 5s💀😦😦😦...
It is not just you 🙂
Damn... Thought I was tripping, but how do u cope with this?
I don't :/
Somethings in life you just gotta bear handling. Like my laptop being a turtle and the current quarantine lol.
LOL... Indeed... U're right
Personally, yes, I agree. In fact, Jekyll used to be criticized for this but has made enormous improvements in this area. I tend to favor Hugo partly for this reason - it is blazing fast. The fact that it is written in Go, shouldn't be a concern for most folks as all you need to learn is the templating - and you can still use your frontend framework if you want.
Yeah, i guess for performance reasons Hugo is getting more popular by the day.
Guess I am not allowed to rant because it free....(but wow!)
Fact. I've tried 11ty too. I'll second that. I haven't tried Hugo but they say it's build time is faster than any other SSG... With Gatsby I even feel like it's slowing my computer too...
Yeah, Hugo is definitely the fastest.