May 13, 2016
Static content is any content that can be delivered to an end user without having to be generated, modified, or processed. The server delivers the same file to each user, making static content one of the simplest and most efficient content types to transmit over the Internet.
Most modern websites are always changing. Websites frequently adapt their layout, content, and available features based on who accesses it. In many cases, a website will deliver entirely different content to one user than another user, even if their requests are less than a second apart. This content is known as dynamic content, since it can change on a per-request basis.
Static content, on the other hand, rarely changes. It doesn’t depend on user input or preferences. While static content is less interactive than dynamic content, it’s generally faster to cache, process, and deliver.
How Static Content Works
Fetching a static asset from a server is one of the basic functions of the web. For example, typing the following URL in a web browser (http://www.example.com/index.html) fetches the file index.html from the server hosting example.com.
There are three steps to requesting static content from a server:
- A user sends a request for a file to the web server.
- The web server retrieves the file from disk.
- The web server sends the file to the user.
Benefits of Static Content
This section isn’t meant to promote static over dynamic content. Almost every website uses a mix of content types to provide a balance between speed and interactivity. However, there are some clear benefits to hosting static content:
- Static content does not change. Once a static file is uploaded to a server, it does not change until you replace it with another file. In the meantime, users who return to your website will see exactly the same content.
- Static content is easier to cache. Although there are tricks to caching dynamic content, it often can’t be cached effectively because it’s hard to predict when it’s needed. Since static content is the same for all users, it can be cached very easily.
- Static content is less power-hungry. Dynamic websites contain layers of application logic that run before the user receives a response. Static websites only need to pull files from the disk. Additionally, techniques such as compression only need to be applied once to static content, making it very resource-efficient.
While static websites drove the initial growth of the web, most of today’s websites are dynamic, user-driven applications. Although the days of the early web are over, some web services are working to merge the performance gains of static websites with the usability of modern web platforms.
StaticGen provides a leaderboard of website generators that build static websites from dynamic content. Meanwhile, platforms like WordPress support static content generation through plugins like the WP Super Cache plugin. It’s unlikely we’ll revert back to static web pages, but we can take advantage of the speed and simplicity of static content to boost the modern web.