2019 seemed to be the year that the term JAMstack started to really grow in popularity with more web developers than ever before. It is approach that I have believed in for many years. Netlify (where I work) was created to enable exactly this type of architecture and indeed coined the very term.
But JAMstack can sound confusing. There are a number of emerging interpretations. In my opinion, there is one aspect of JAMstack which absolutely key: Pre-rendering.
Here is a short explanation about why.
By "pre-rendering", we mean, "to generate the site in advance". This is different to generating each page view in response to a request from a user which is a more traditional model these days. Pre-rendering brings a number of advantages:
- Speed. When all the work of turning data and templates into markup is done ahead of time, serving a response is faster than doing it on demand.
- Security. Since we pre-rendered our response, we can serve it as static assets. This has huge advantages in terms of complexity and security of hosting infrastructure.
- Scale. Traditional "dynamic" stacks which assemble each response a la minute struggle at times of heavy load. Capacity planning is an art in itself. One strategy is to introduce complex caching layers to hold static snapshots of common database queries, commonly used assets, or even common page views. But a pre-rendered site can be cached at a CDN by default. No more fearing being "slash-dotted".
- Certainty. While some are excited by the aspect of JAMstack which suggests serverless hosting (indeed, JAMstack can take maintaining a webserver refreshingly out of the equation), describing JAMstack as serverless hosting is only partially accurate. Serverless can be a wonderful companion to JAMstack sites (I'll save that for another post). But by pre-rendering our sites we can be certain that our pages are correct before we deploy them. I like to talk about putting distance between the user and the technical complexity.
Back in the day, all web sites were built this way. We crafted assets and served them statically. Later we introduced mechanics like cgi-bins and databases to make the content on sites dynamic. Soon we turned our backs on the advantages inherent in serving static assets.
But at its heart, the unsung hero of the stack, is pre-rendering as much as possible and enjoying the many benefits of working with, and serving static assets.
To learn more about JAMstack, you could dip in to the book I co-authored with Netlify co-founder, Matt Biilmann. Available free to download as an ebook: Modern Web Development on the JAMstack, (O'Reilly, 2019)