PHP Reloading data on interval, not refresh

169 Views Asked by At

i have a php script that scrapes data from a bunch of websites and stores them in a db. What i want to happen is instead of having the php load at every connection, i want to set it on a 10 minute interval that then stores the data it gets into a DB so i can instantly retrieve info instead of having to have the php run everytime which takes up time. I don't know ajax well and would like to keep it as php/mysql as possible. Any help is apreciated.

TL;DR: Want php to save data to a db every 10 minutes then output that db the same way until it gets over written, instead of loading new data on a refresh.

1

There are 1 best solutions below

0
On

Basic options as follows. No need (or use) for AJAX here.

  • Make a cron job / scheduled task (Linux / Windows) that calls your script at intervals.

  • Add a timed javascript browser refresh to your PHP script. See here for how.

  • Use a browser plugin like "Easy Auto Refresh" (Chrome) or "ReloadEvery" (Firefox).

The first one is the cleanest way around, spares you from keeping a browser tab open.