DEV Community

Discussion on: What are the benefits of using a static frontend?

Collapse
 
xwero profile image
david duymelinck

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.