Hi all,
I am currently writing an application in PHP 4 / MySQL which mainly consists of displaying the results of various queries...
So far, nothing special.
So I started to write the queries and show the results in tables like most people do. Then I became aware of a fact that didn't initially strike me : that almost all of the displayed results are actually not user-specific.
It is a kind of reporting site.
I mean, all users are hitting the database with the same queries again and again.
But each time a new visitor loads a page, the query is submitted again, while its results won't be any different from those that were returned to the previous visitors.
This would make sense if the database was updated very frequently, every few minutes of even hour, but that's not the case. I expect the database to be updated once in 24 hrs perhaps. It is also not vital that visitors get the updates at the minute they were made.
So it is huge waste of server resources.
I would like to know how to have the server query the database in a single shot only once in a while, every 24 hrs for example, and get it to return the same resultsets that were obtained to all visitors until the next day.
I could for example put all the results in global arrays or objects, but how to tell the server to refresh them in a fixed interval ?
My question boils down to : is there any way to cause some kind of server-wide resource initialization ?
The site is on shared hosting so I can't
control server reboots.
Perhaps I am taking this the wrong way and there is an entirely different solution to this problem... feel free to comment
Thanks in advance 🙂