isn't that what a CDN is for?
For further actions, you may consider blocking this person and/or reporting abuse
isn't that what a CDN is for?
For further actions, you may consider blocking this person and/or reporting abuse
HolaWagtail -
james -
Aarav Joshi -
Mohamed Ibrahim -
Top comments (9)
A few reasons why people (like me!) prefer building static sites to server-driven dynamic ones, even ones cached on a CDN:
These are basically the exact reasons I went from WordPress to Jekyll for my personal website and could never go back. So much stress in setting up and updating it is now gone. Plus it was relatively easy to work in tools I wanted like Tailwind and Turbolinks.
Exactly this.
To add, decoupling the frontend and backend can also be useful for client work. Clients love CMSs like WordPress because it's easy for them to mess with things, but sometimes they mess with things that they shouldn't. By decoupling things, they have the ability to make changes to content, but not to the frontend unless they know what they're doing.
Here's a good read that goes into why people would use a static frontend on a WordPress backend:
northstack.com/static-wordpress-fr...
The way to create a website is by creating html files and those are shown by the web server. Because people wanted to change those html files without learning html/css/js programmers created content management tools. Those content management tools use a database to collect how the html should be generated. Because the people demanded a lot of features generating html became slow.
That is why programmers came up with caching. Basically this is another database with pre-rendered html that sits between the content management tool and the web server. When people go to an url the database checks if it has html. When it has html it will return it. When it doesn't it lets you go to the content managment tool to generate the html, stores it, and displays it.
The problem with caching is that it still requires a database, it is faster but it still takes time to check.
There are also cases where people want parts of the html to refresh faster than others. For example when a new related page link/preview needs to be shown.
With static site generators you cut out those databases because you create the actual html pages. Each change will regenerate the whole site, which means the html files are always up to date.
If you ask why the programmers didn't use static site generators from the start. The answer is that it used to be much harder to set up web servers than it is at the moment. Now setting up new web servers is done virtually, that means there can be multiple web servers on one machine. Earlier it was one web server per machine.
So now when you change content a virtual web server is set up, the static site generator runs, the old web server gets switched to the new. Than the old web server can be used as a backup or can be removed to make place for future updates.
Most of the reason I switched to static front-end are bad experiences with server-side UIs. Primarily, the bad performance of round-trips back to the server to re-render the UI. A browser-based front-end can switch pages immediately and remain responsive while data is loading.
In most of the apps I write, browser (or CDN) caching of whole pages is not desired as data changes are frequent and need to be reflected quickly. It would be impractical to invalidate CDN caches as data changed. Instead, the back-end database (or caching subsystem if necessary) handles caching of data. So repeated requests for the same data remain fast. The front-end assets are still browser/CDN cached, since they don't change as often.
In general, it makes for a good separation of concerns. When I did server-side UI, it was all too easy to mix UI and integration concerns, leading to more difficult maintenance in the long term. With good practices, you could avoid this mix of concerns on server-side UI. But it is less intuitive compared to when front/back are split.
A split front/back also allows two people/teams to work effectively in parallel, provided they agree on the data structures that pass between.
I'd say this is astutely correct. DEV, for example, does compile and serve a lot of pages as static, so for the end user it shouldn't make a big difference whether our site was "statically compiled" or "built by a server and database but cached via a CDN".
I think a lot of it comes down more to the developer experience and reliability of the whole application. There are tradeoffs in terms of what could go wrong and why for each approach, a different set of tools for different styles, etc.
The constraint of static frontends, in the JAMstack universe offers inherent guidance as to how to build a complex application, where typically the shell of the app is shipped and the data comes next. This imitates installable applications in a way that some developers might find helpful for their process.
Hope this helps, if anybody thinks I'm off base with any of this, feel free to weigh in.
I think the DEV approach is what ZEIT called Serverless Pre-Rendering, without the
less
.I think you've pretty much nailed all the reasons.
I would maybe add SEO, but that's not necessarily a static site feature.
Routing animation is much much better on SPAs...