Save to database or generate new html page?

Asked

Viewed 628 times

1

I’m doing a news portal. The administrator will feed the system through an administrative panel. To working with php and mysql. The question is: generate an html file for each new news? Or save everything in the database? Both methods work, but which is better?

  • 1

    Guy I recommend you save in the bank.. as the system grows better for maintenance is a more dynamic springboard..

  • Generate an html file for every new news is crazy.

1 answer

3

Without any doubt, you should store the news in a database.

Creating a page for each news story is completely unviable. It only works on static content sites that don’t change.

Think of the following points:

  • You will need to edit news, whether to correct or add information
  • You will need to include ads, even if not now, to monetize your portal
  • You will need, over time, to change the layout of your portal
  • You will need to have control of statistical information, monitoring tools and user control. All this is done with server-side programming, you do not want to do all this whenever you launch a new news, it is not?
  • Sometimes a system of comments is required

There are many other points to mention, the advantages of using the database are endless.

The only advantage of using HTML files that I can see would be the performance gain, which will not even be so great if your portal is small, with few access. But, this you can get around in a very simple way using PHP to create some cache system and this goes according to your needs. In most cases it will not be necessary.

An example of a simple and efficient cache system is to create a table in the database and store all the values needed to mount a particular page. You still need to query the database to get these values, but instead of doing for example five SQL queries, you will only do one query. You will only make the five queries to assemble the page once a day or when the system owner update some information on the page in question and at that time you create your cache that will be used in the other visits.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.