Webpages and in turn websites can generally be classified into two broad categories: Static and Dynamic.The basic difference between these two types of web content is how it is created or put together each time it is accessed.
In order to understand the differences between static and dynamic webpages, you should know how a webpage is put together. There are virtually an infinite number of ways that a webpage can put together. The content can be inserted into the webpage using several different web technologies either on the client side or the server side.
What is a Static Webpage?
A static webpage is one where the content of the page is constant every time it is loaded or accessed. The content of a static webpage do not change no matter who, when and where it is loaded. Because the content does not change, you can code the content directly on to the page source code.
Typically a static page does not need to be assembled (or re-assembled) at the server side. The request for a static webpage will result in accessing only static resources such as HTML page source, images, CSS and JS files. There are no further server side requests or data access such as database queries or executing code on the server.
An example of static webpage is an HTML file. The same HTML file along with the related static resources is delivered each time the page is accessed. It is easy to confuse between static webpages and pages with static content. Static webpages will always have static content, but not necessarily the other way around.
What is a Dynamic Webpage?
A dynamic webpage can have differing content each time it is loaded. Its content is generated on-the-fly each time the client makes a request. These types of pages are put together using a different set of web technology such as JSP, ASP, PHP, Java, .NET etc.
Every time a client makes a request for a webpage, the server analyses the request and generates the content specific to the request by executing some server side code and/or querying databases or other back-end systems. It is this execution of code on the server side that makes it different from a static page.
It is quite possible for you to use a dynamic page to serve content that is mostly static. It is probably not very resource efficient, but it is possible to create a static-content webpage using dynamic web technologies.
Most modern day websites are purely dynamic. Some examples are your web email (eg.Gmail), message forums and blogs (eg. WordPress).
The client side scripts allow the static webpages to be a lot more dynamic in its display of content. These client-side technologies allow you to execute code on the client side after the content has mostly been downloaded, as opposed to the traditional model of server-side computing.
As these technologies does not necessitate any server side computing, thus we should consider it to be a static page for all practical purposes. It is also possible for these resources (eg. JS pages) to be downloaded once and cached effectively on client side browsers. Both static and dynamic webpages benefit from client side technologies.
There are several advantages in using static webpages as opposed to dynamic webpages (and probably vice-versa). Let us take a look at some of the pros and cons of each type of webpages.
Advantages of Static Websites
Static pages are the fastest way to serve content. It makes the best use of web and proxy caching. The content can potentially be cached for a very long time as it is not likely to change or expire soon. This can be a big factor in SEO.
It is also one of the most resource efficient way to serve content. There are really no resource intensive server side processing to be done and the URL (webpage) and all relative resource URIs map to static content or files.
Static webpages are also the safest way to serve content. As there is no server side processing or any back end storing data, it is virtually impossible to hack or get your server to perform any unintended actions. The only vulnerable part is the web server and not your website. The traffic is mostly from the server to the client and there is no interaction with the server afterwards.
Static page are easier and faster to code as there are less moving parts. It is also faster to production, as there are less testing to be done compared to dynamic pages.
As it is easier and faster to develop, it is also cheaper. The development costs can be considerably cheaper. It is also cheaper to host than dynamic websites. You do not need any server side environment or framework to execute code, and a simple HTTP web server is sufficient to host. You should mostly be paying for the bandwidth and nothing much else.
Advantages of Dynamic Websites
Easier Content Updates
The content for a webpage is generated dynamically on demand. This makes it easier or faster to update content on your webpages. All you probably will need to do is update or create the content on the back-end servers and your content shows up dynamically on the webpage at the very next reload of the page.
User Appeal/User Interaction
Users tend to like webpages with an ever-changing content. Dynamic pages support user interaction such as support for comments (although it is possible to have some comment support with client side technology), support for web forms, user logins etc.
User Targeted Content
It is possible to tailor the content specifically to the user who is viewing the page. You can support user logins or other user identification techniques that will allow you to display unique and specific content on the fly. You can also display dynamic content based on user input.
Every website is a combination of several webpages. As it is each individual webpage that can be static or dynamic, it does not really make much sense to categorize a entire website as either dynamic or static. A website can be a combination of both static and dynamic webpages. If the website contains only static pages, then the website is a static website. If on the other hand, if all or most of your pages are dynamic in nature then you can classify the website as a dynamic website.
So, what is better for your website?
What is better for you, depends very much on the requirements and functionality that you want on your website. Ideally, your website will be a combination of both static and dynamic pages. I have always been partial to static content, and this is a static website even though it is a blog and is developed using WordPress.
It is advantageous to create your pages to be static unless you want the dynamic functionality. Using dynamic technologies to create static content is probably not the best of ideas (even if you are using caching). Web pages such as About Us or Product/Service Descriptions (unless it is e-commerce) are prime examples for static pages. And webpages that need to be constantly updated, especially those based on user input or the state of other underlying systems will need to be dynamic.