do you really need instant dynamic freshness?

I fear that this little rant will be far to concrete. Meta-programming monologues is what I expected to write when revamping my website. However, one can only be vague for so long. Currently I find myself analyzing static versus dynamic websites, so prepare for a small amount of actual tech.

Some definitions: static websites to me are the ones constructed out of actual files. The webserver gets a request and returns an actual static file. Dynamic are the ones where the request by the webserver is passed through some code, generating the html, probably consulting a few databases and stitching everything together before returning the entire thing.

Dynamic websites are pretty much the norm for modern websites. Even most low-tech blogs and other small websites are run on a dynamic system. Running a site this way makes it easy to manage data in an administrative backend. It also means you can create relations between data, query those relations and manipulate that data with a programming language. However, its also:

  • Puts load on the server for every page requested. Every roundtrip requires database queries, programming languages doing their magic, et cetera.
  • Costs time. Next to load on the server, that server also needs time to work out the request and give something back
  • Creates unsafety. The dynamic code handles external requests. Bad people can send bad requests, attempting to abuse your system.

But, foremost: it isn’t necessary !

Take this article for example. It will probably never change. I might do something about my horrible spelling, fix some of my non-native speaker related English quirks. When this happens I will do it once. There’s no reason every time someone visits this page, a whole array of query’s and programming should be working to get the latest version. It’s a waste!

Therefore, I use Jekyll. A generator that creates a static site every time I edit something. Simple, elegant, robust. Changes are pushed every 5 minutes, though that could be reduced to 1 minute. To me, that’s almost instant. 5 minutes is more than fast enough. 80% of use cases do not need instant change or updates.

I’m liking this idea so much that my mind is set on building an ‘advanced’ website using this technique. It will be fast and sturdy. Any dynamic needs can be fulfilled during the generation of the website. Only one time will smart programming and databases do the heavy lifting, ‘compiling’ my site. After that it’s pure smooth static sailing!

Yes there will be issues. I will at some point need to remember user settings, or even accept some user input and store it somewhere, after which it should be shown on the site. JavaScript and AJAX will hopefully save me then. Only things that really really need to be dynamic, will be dynamic.

How much ‘dynamicness’ do you really need?