Save to database or generate new html page?

1

To make a news portal. The administrator will power the system through an administrative panel. I'm working with php and mysql. The question is: generate an html file for every new news? Or save everything in the database? Both methods work, what is the best?

    
asked by anonymous 29.06.2017 / 04:47

1 answer

3

No doubt you should store the news in a database.

Creating a page for each news item is completely impractical. This only works on static content sites that do not change.

Consider the following points:

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

There are many other points that I would point out, 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 be as great if your portal is small, with few hits. But, this you can work around very simply using PHP to create some caching system and this goes according to your needs. In most cases, it will not be necessary.

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

    
29.06.2017 / 05:05