A website, or individual web page, can be static or dynamic. A static website or static web page contains information that doesn't change automatically. It remains the same, or static, for every viewer of the site. A dynamic website or dynamic web page contains information that changes, depending on the viewer, the time of the day, the time zone, the viewer's native language, and other factors. For example, the Computer Hope home page is a dynamic web page that automatically changes daily to give visitors new content. However, this page you're reading now is a static page that remains the same until it is updated.
A dynamic website can contain client-side scripting or server-side scripting to generate the changing content or a combination of both scripting types. These sites also include HTML programming for the basic structure. The client-side or server-side scripting takes care of the guts of the site.
With server-side scripting, scripts are run on the server that hosts the page. The process for how the page is built is determined by parameters defined in the server-side scripting.
Why would you choose a dynamic page over a static page?
The following are some of the many reasons why a company may need to have a dynamic page over a static page.
Need to access a database or external file
A page that needs to access a database or external file to get information needs to be dynamic. For example, when you visit Google and perform a search, Google sends your search query to hundreds of computers and combines all information from those computers into a search result page.
Information is updated frequently
Websites that have information that's updated frequently are dynamic to make it easier and faster to get information online. For example, a news site may have many different reporters who can submit stories. With scripts, the company can automatically update the home page to contain those stories without relying on someone to edit a static HTML page each time a new story and page is added.
Dynamic sites make it easier for everyone to contribute
WordPress sites and other CMS solutions make it easier for anyone to have a website without knowing a lot about HTML or programming. Once created, the user(s) can create pages using an online editor and post them online using the CMS. In contrast, a static website would require that the user create the page in an HTML editor and upload it using FTP.
Why would you choose a static page over a dynamic page?
The following are some of the reasons why a company may choose to have a static page over a dynamic site or page.
A static HTML page always loads faster than a dynamic page generated server-side because it does not require an external resource. Server-side dynamic sites require at least one request be made to a database or other file that increases the load time.
Most CMS solutions allow pages to be created dynamically, and then when published, create a static page to help it load faster.
A static HTML page does not require an external resource, like a database, which allows the page to work anywhere. For example, the page can be viewed offline and cached across multiple servers around the world using a CDN.
Lower server requirements
By not needing a database or any server-side script to load the page, a static HTML page requires a lot less system resources. Requiring less from a server allows it to serve more visitors and perform a lot faster than a server serving dynamic web pages.