Monday 1 September 2014

Static or dynamic?

Back when I first set up a web site, there was an initial decision to be made - static or dynamic?

With a static web site, all the pages are html files, and once the file is made, it's fixed. The web server (which these days is usually Apache), reads the file and sends it to the user's browser.

The alternative is dynamic. You have a database (usually an SQL system, often "mysql" or, these days, "MariaDB"). Each time the user accesses a page, that runs a php program which queries the sql database, and the result of that query is sent to the user's browser.

The advantage of dynamic is that it's dynamic. Which means that if a page includes comments, for example, then the page will change as each comment is made, and the system shows the latest update each time the page is viewed. The big disadvantage of the dynamic system, is that a lot of computation has to be done every time any user accesses the system. This can be a big load on the server, and as a result, it can be slow.

Wordpress is dynamic. If you google "wordpress speed" you get 68 million results, with titles like  "15 Easy Ways To Speed Up WordPress", "5 Quick Ways to Speed Up Your WordPress Site", "13 Ways to Speed Up your WordPress Site". I didn't see a single page saying "wow, wordpress is so fast!".

The first impression I had, after installing Wordpress and putting up a very simple site, was "wow, this is so slow!". And I'm accessing it on my internal network, which is 100 megabits.
And this is because it's dynamic. In this case, "dynamic" translates to "slow".

If you want to run Wordpress, you're stuck with this. The advantage of Wordpress, is that it's what 10 million other web sites use (or maybe it's 55 million). There's other blog software, but there's a big plus in using what's used by a great many other people. But once you've chosen Wordpress, you should expect slowness. You can mitigate this, perhaps - google "speed up wordpress for 37 million articles suggesting how.

So, back when I set up my first web site, what did I do? I wanted the speed of static, with the flexibility of dynamic. I got that, by using straight html files served straight from Apache, but once per day, a process ran that looked at all the pages, decided whether they needed to be updated, and updated them if necessary. So the computation for creating the page was done once, not every time someone accessed it.

The exceptions to this, were the message boards I set up; if you accessed the message board, it read the latest file of text for display. No sql database, no php, just a perl script. And the chatroom worked the same way. But the majority of the site, more than 99%, was static (but updated daily).

This seems to me to be the ideal solution. Static everywhere except where things really do need to be dynamic. But this doesn't seem to be a solution that's generally used, and I don't know why.

No comments:

Post a Comment