About A Webmaster - What You Need To Know

Statically Generated Content

July 11, 2005

Another method you can use to get your data from your database out to browseable web pages is to use a script that will write individual files from the database to the file system. This will require a field in the database to indicate what name/path the file should be written to. To keep it simple, every time the script is run, just have it loop through every page in the database and for each one, write the page's content in the appropriate location.

The major advantages to this method are that you can have your database go down and your website will still work and this solution scales much better than the solution previously discussed. The reason this method scales so much better is that there are no calculations or queries to run on-the-fly. The end product is a file system full of plain files, just as if you had hand coded each one.

The one major disadvantage to this method is that any changes made to your site in the database are only reflected to your visitors the next time the script is run. This means you either have to run your script every time you make a change or set a cronjob to run at set intervals (once a day, once an hour, once a minute...) to minimize the time between a change and the resulting website update. This is an insignificant problem if you run a content site where you have a handful of contributors and new content only appears a couple of times per day. For others this problem can be a show stopper. For sites that use forums, customer feedback or any other type of user feedback, there can be no lag between the addition of content and its presentation. Sixty seconds may as well be an eternity.

Page 5 of 6