Tiago.codes

Why static sites aren’t as bad as you think

Posted

Static sites bring us back to the early days of the web. When websites didn’t pull information from a database and template engines were not a thing. Simply HTML pages being served.

Technology has evolved substantially since then. While this has allowed complex projects to be built effortlessly, many smaller, simpler websites have become over-engineered.

Over-complicated manual watering machine
Over-complicated manual watering machine

How are websites served?

When someone enters a website’s address in their browser, a request is sent off to the internet asking for access to the web page found at that address.

A web server will then respond to that request and deliver back the content of the page to the user.

How a website is served
How a website is served

Every website needs a web server running behind the scenes. Sometimes web servers have to deal with a lot of processing, resulting in slower response times and therefore slower websites.

Static vs dynamic

Static sites generate static content. All pages are generated before they are uploaded to a server. They are only updated (or re-generated) if someone makes a change to the content.

Dynamic sites have to generate the content every time before delivering it. This usually means combining page templates with information pulled from a database.

Serving static vs dynamic sites
Serving static vs dynamic sites

Simple projects can really benefit from having a static site. More complex projects will probably need dynamic content generation. Both have its pros and cons.

 StaticDynamic
Data sourcePlain textDatabase
ScalabilityLessMore
Content generationWhen making changes to the contentEvery time a page is requested by a user
Page loading timeFasterSlower

All static sites can be turned into dynamic but not all dynamic sites can be turned into static. Choosing the type of website depends primarily on the complexity of your project.

For instance, if you’re not 100% sure you need to store your website’s content in a database, you can probably have a static site.

Taking a database away from the equation can be a big step towards simplification.

Benefits of going static

You could potentially benefit from having a static site. A lot of good things come with it.

  1. Simplicity

    Very few moving parts. It’s easy to build and therefore less prone to human error.

  2. Speed

    As fast as a website can get. All pages are pre-generated and the web server doesn’t need to spend time communicating with a database server or generating dynamic content.

  3. Security and reliability

    Limited exposure to the internet. Standard injection attacks are usually not possible and the lack of database operations means additional immunity to security exploits.

  4. Affordability

    Very cheap to run a server. It doesn’t need extra resources to run a database or a template engine.

All of this while still being able to use a CMS.