Static vs Dynamic websites - The pros and cons

Static vs Dynamic websites - The pros and cons

In this article, we’ll explore the considerations needed when choosing between a static or dynamic website. For the purpose of this article I’ll define website as a small collection of informational web pages that are designed to be read, as opposed to a large business web application with complex rules and logic.

The difference between a static and dynamic website

Many years ago, during the early era of the internet, most websites were static websites. They were just a collection of pre-written HTML, Images and resource files. To make a website each page would have had to be manually created and maintained. This simplicity was also one of the major drawbacks to static sites. Making an update to the layout required each page to be painfully edited manually.

Today most websites are dynamic. They are database-backed and powered by a server-side programming language like PHP or Asp.net. If they display custom content generated for each user, or are powered by a content management system (CMS) like WordPress or Drupal , they would usually be considered dynamic.

Dynamic websites generate HTML pages by combining the websites content with an HTML template on the fly whenever a user asks for a page. Making an update to the layout of a dynamic website is more straightforward. You simply edit the HTML template and the change will be reflected across the website.

In recent years, static site generators like Jekyll and Hugo have stepped in to close the gap between dynamic and static websites. These tools create HTML pages combining web content with HTML templates. The difference is, this happens once during the build stage and the HTML files are ready for hosting.

Whilst many sites today are dynamic, do they really need to be? Do you need a dynamic website or would using a static site generator suffice? To help you decide, I’ll outline some of the advantages between the two.

Advantages to a static website

  • Faster speed - Since you are just hosting and serving static files, when a user visits your page, all the web server has to do is return a file. No server-side code is executed. With dynamic websites there is extra processing time required to deliver HTML pages. Caching can be applied to alleviate this issue on a dynamic website but it increases complexity.
  • More secure - Since there is no back-end server-side processing, there is less surface area for attacks and there is no database available to be compromised.
  • Lower costs - No database means fewer moving parts and less maintenance. Static websites can be hosted relatively cheap.
  • Easier to scale - Host your website on a Cloud provider with auto scaling and you are good to go. Use a Content Delivery Network (CDN) to geographically cache your static files and the calls to your web server will be drastically reduced. Although similar techniques can be applied with dynamic websites, it will be more complex as database scaling might be required!
  • Backups/Full editorial history - Indirectly when using version control such as GIT, you get full control to see who changed which content and when.

Advantages to a dynamic website

  • Easier to update content - Using a CMS web interface for managing content will allow you to make changes easily. For example, you can add a blog post on the go from on your mobile. With a static site this is not as convenient for the non tech savvy.
  • More flexible - When creating your own dynamic website, you have full control of the wheel to create whatever interactive feature you like.

Conclusion - Which one is better?

If your website is intended for non-techies to manage or a bespoke business feature is needed, a dynamic website would be a better choice.

If your website doesn’t change that often and all the features you need can be implemented with a static site, I would most certainly opt for this. The tools in recent years have helped alleviate most of pain points of the past allowing us to enjoy the many advantages today.