I’m writing a view that will have daily/weekly/monthly report data. I’m thinking it makes sense to only run a query periodically to update the data rather than hit the database whenever someone loads the page. Can this be done completely in PHP and MySQL? What are some robust ways to handle this?
I’m writing a view that will have daily/weekly/monthly report data. I’m thinking it makes
Share
Using a templating engine like Smarty that supports caching, you can set a long cache time for those pages. You then need to code your PHP to test whether your date constraints have changed and if the data is not already cached, and if either of those conditions is true, perform the query. Otherwise, Smarty will just load the cached page and your code won’t query the database.
Further documentation on Smarty caching