As a rule of thumb, dynamic sites use server side languages to process requests at the time it’s made and generate a page and its contents in real-time. Static pages are pre-rendered, cached, and delivered to the user.
When we think back to the beginnings of the internet, all web pages displayed the same content to every user. Over time, websites integrated with databases powered by languages like Python, PHP, ASP, Ruby, Java, and more. This enabled sites to be dynamic, and display relevant content to the user based on a setting or input.
Before proceeding, it’s important to understand that for our purposes in this article, dynamic and static refer to how a page is being delivered to the user. gjstatic Sites can be dynamically generated, cached, and served statically. Static sites can have dynamic components. What we’re referring to throughout this article is generally how a site is rendered, either by the server at the time of the request (dynamic) or pre-rendered and delivered via CDN (static).
What’s a Dynamic Website?
Dynamic sites use server side languages to process requests at the time it’s made and generate a page and its contents in real-time. This means that dynamic websites interact with the user accessing the site and render content depending on the user’s actions or settings. One example of a dynamic website is web apps. Take Twitter as an example: when you log in, it displays content just for you.
While dynamic sites are extremely powerful they are also more complex. Along with this complexity are many advantages and disadvantages inherent to a dynamic site build.
Dynamic Site Advantages
Powered by Databases
By connecting a dynamic site to a database, you’re able to easily request information in an organized and structured way to create and display content depending on how the user wants to view it.
Connect to a CMS
This ability to connect to a database means that you can also connect to a CMS. Content stored in the CMS can be a variety of things, from the text to the images that are displayed, page layouts, site settings, and more. This allows for extreme flexibility when building sites, and also allows for multiple users to be able to manipulate content as needed.
Low Ongoing Maintenance Cost
Since you can connect a dynamic site to a CMS there are little or no ongoing costs unless there is a change in the basic design or an extra capability is added to the site.
Dynamic Site Disadvantages
When generating content on a page from a database, you’re typically pulling in content and telling it to display a certain way, no matter what the content is. This can make design tricky, as you’ll likely opt for a one-size-fits-all approach. Depending on the CMS, it can be difficult to build multiple designs to display different types of content in different types of ways.
With dynamic sites, you are forced into using templates for your page, or you are committing to building custom templates for every page. This is easier in some CMSes such as Zesty.io but harder to do in others such as WordPress or Drupal.
Can Incur Upfront Build Costs
When building a dynamic site, it can incur much more work upfront as you’re connecting the site to a database, building the foundation for the site to generate content, etc. Additional functionality may also cost more as you add features to your dynamic site throughout its life. While maintenance costs are low for a dynamic site, they can incur much higher initial build costs than a static site.
What’s a Static Website?
Static websites are pre-rendered, typically cached, and served by a CDN. The site is pre-generated by individual files that are delivered to all users in the same manner. There are advantages and disadvantages to choosing to build a static site.
Static Site Advantages
The main advantage of a static site is the flexibility it offers. Every page can be different; designs can change, layouts can differ, and the designer doesn’t have to make one design fit the mold for multiple types of content to display on a page.
Cost can be lower upfront to build a static site than to build a dynamic site. Since pages don’t have to be connected to a database to generate content and render the view, they can be less expensive than a dynamic site to build. However, hooking up a headless CMS to a static site generator and then a delivery network can make a static site expensive to build.
Since static sites are pre-rendered, the load times are very fast. Without complex scripting, a database, parsing content through templating languages, etc. these sites typically load in a snap.
Static Site Disadvantages
More Difficult to Update
Static sites can be challenging to change once they’re built- even making small content tweaks can be challenging. Unless you are familiar with HTML, CSS, and the code of the site, you may have to ask your developer who originally built the site to make changes to the site for you.
More Difficult to Scale
Adding to a static site over time can also be more difficult than with a dynamic site. For instance, creating product pages means that you have to construct a new page every time you want to add a new product page, which can take time and incur ongoing maintenance costs.
Ongoing Maintenance Costs
As mentioned above, adding to your site or making changes to it will incur costs. This means that, over time, maintaining a static site can incur ongoing maintenance costs that you may otherwise avoid with a dynamic site.
When do I need a dynamic or static website?
There are lots of situations and types of sites that you may be looking to build that make it confusing to know if you need a static or dynamic build. Typically the answer is, if you’re looking to connect the site to a database to generate content in real time, it’s dynamic. Here’s a few examples of builds and whether they’re static or dynamic: