How to Use a Center Seat Belt that Comes from the Roof (and is it safe??)

I am wondering whether it is bad practice to store commonly used standard static webpages such as the home page, 'contact us' page, login page, etc. in a database instead of as static files saved on the server?

In particular, if so, does this extend to when the static webpages share a reasonably large amount of style with dynamically generated webpages?

I suspect the answer is that it is all bad practice due to loading times increasing from the database connection and retrieval, but I've not performed my own benchmarks and cannot find any answers one way or the other online, so I thought it best to check.

  • 1 If you think about it, this is practically how all dynamic sites are run. Via database calls that is. And dynamic sites are still pretty prevalent and fast. But this all depends on the efficiency of the server. So you basically have static data being called like a dynamic site would be.
  • @Bigbob556677 I do have other parts of the site which are dynamic, which is why I have the database set up already, but I was unsure of whether using it needlessly was bad practice.

Speed is always of the essence, so there is nothing wrong with delivering pages that do not require a database query. Best case scenario you have some caching in place (i.e. Browser, E-Tag or Application-Level caching). So yes, you are right to minimise or avoid any database query on static pages such as about-us, privacy/cookie policy, ToS, and other pages. The page will score high in terms of user experience - from a speed perspective. Everything else needs to be optimised as well. For example, the standard SEO on-page stuff, as well as making sure the site is user-friendly across all user devices.

The only thing I am a bit concerned when reading your question is - what do you mean you store static pages on your server? You mean, you want to store 'about-us.html' file somewhere in your 'www' folder and then link to that page? If so - my answer is no.

I have little experience in terms of CMS. However, if you work with systems like Wordpress, Joomla, Typo3 or Drupal, the contents of your pages will be stored in a database. There's no way around this and generally speaking if you are after performance, stay away from Wordpress & Co.. This is a very subjective opinion by me - a grumpy, nerdy developer :P.

We usually develop our applications and sites for clients in Web Application Frameworks, i.e. Rails, Django. There are plenty, and it depends on the use case to decide what the prefered framework is going to be. The bottom line here - you can then create controllers for views that do not access the database but display the content you place in the corresponding view. Ergo - making it static.

On top of that, you can cache the content. Wo when the request comes in, the application sends the page right back without starting to process anything at the application level — making it super fast and efficient.

none: Charles Robertson | none