views:

20

answers:

1

I've got a database site that will serve approximately 1,200 primary entries at launch, with the prospect of adding ~100 new entries per year. Each entry would be composed of ~20 basic values from the database, as well as a calculated average rating, and a variable amount of user comments.

The rating and comments output would have to be generated upon page request, but the rest of the data would be static unless an error correction had been made by an admin.

Considering bandwith, database load, and download times - would it be better to just generate the entire page on the fly with a few queries after a GET or would it be better to have html files and append the ratings & comments then write a refresher script that would update all the html records when run?

In my mind the pros & cons are:

On-the-fly
+ saves hosting space by building pages only when needed
- leaves nothing for a search engine to find?
- slightly slower due to extra queries

HTML & appends
+ search engine friendly
+ slightly faster due to less queries
- uses disk space
- slightly more complex code requirements

Neutral
= templating would be the same either way

Thoughts?

+1  A: 

Do whatever's easiest to code: you'll find that in practice all your pros and cons are actually the same for both options.

Personally, given that you will have to go to the database anyway to deliver the comments, I'd go for a completely on-the-fly generated page.

Creating a web page dynamically from 1,200 database records -- in fact, frankly, 1,200,000 database records -- are well within the capabilities of MySQL and PHP on even a moderately specified shared host. There are plenty of examples of sites that use this combination with millions of records so you won't find performance to be an issue for a long time!

And as it happens you'll probably not save hosting space as the database records take up space on the host in the same way that static data does.

A search engine will replicate what a user's browser does. It issues an good ol' HTTP GET request to the root of your site, then analyses each of the links and requests each of them until the spider has got every page that it can. So to make sure that a database-driven site is indexed by a search engine, provide <a href="http://linkgoeshere"&gt;Link text</a> links in your page to each record.

Something as simple as an A-Z list of entries with a grid underneath would do - for an example a site I'm working on at the moment is http://arkive.org where we do just that.

Jeremy McGee
Thank you very much for such a detailed and well-structured answer!
Andrew Heath