By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

Static HTML vs Dynamic Websites

This Article takes a look on the performance issues of dynamic websites, and how to avoid them.

Edited: 2013-07-05 10:27

Dynamic pages are generally more demanding then static HTML. But how can we avoid most – if not all of these performance issues?

The answer is caching, and not just throwing a 304 Not Modified response – we will do that as well – but what we really want to highlight, is the gain from saving the generated HTML and loading the saved copy if the page has not been modified.

Caching of Dynamic Content

The generated resources – lets just make this HTML for simplicity – can be saved either in the database, or on disk. Performance wise it makes sense to store it on the disk locally, because a database requires access through higher layers, wheres the disk can be accessed directly. However, the disk in a computer is often the slowest component – unless we are talking newer technologies such as ssd disks.

No matter what you chose, the biggest bottlenecks are likely to be communicating with the database and reading to/from disk.

Another option is to put a caching proxy such as Varnish in front of your web server, this would also avoid having to run server-side code to determine if a page has been updated, and so on.

When to Optimize Caching

Considering current resources available on most servers, there will be gains in performance from caching dynamic content. Obviously this will be the most noticeable on high traffic site, and you might not be able to notice any difference on a low traffic site.

Over Optimizing

Please note, that in a lot of cases this could be categorized as over-optimization – and for most sites this should not be the first place to optimize. But for high-traffic sites, there might actually be money to save.

Then when should we Optimize this?

All CMS systems that are widely distributed, should have it on their to-dos list, at least as a feature that you can enable and disable as you see fit.