I have a PHP page set up to generate a rather large set of data generated from MYSQL queries.
Using this data it will create a certain number of table headers (in html ) dependant on the number of users currently in the system.
foreach($usersFromMYSQL as $row)
{
echo
"
<th>$someUserData
<th>Col Y
<th>Col Z
";
}
It will then also populate the table with a certain of number of rows (in html ) dependant on the number of events occurring in the system
foreach ($eventsFromMYSQL as $row)
{
echo
"
<tr>
";
foreach($usersfromMYSQL as $inner_row)
{
echo
"
<td>$someUserSpecificEventData1
<td>$someUserSpecificEventData2
<td>$someUserSpecificEventData3
";
}
}
This code is heavily simplified, but identical in format, to my website.
My problem is that I am running my website on a Raspberry PI, and the load times for this page are (expectedly) slow due to the number of users and events in the database. Currently each time you access the page all of this data is requested again, and there is (to my knowledge at least) no form of caching or memorisation involved.
The data can possibly change day by day, meaning that if the page where to be cached, I would want it to only remain cached for the remainder of that day, as the next day could possibly have different results.
My question is what solutions exist to prevent this data being reloaded every time the page is visisted, but ensure that it is at least reloaded once a day?