Is it possible?
Moderator: General Moderators
Is it possible?
I'm sorry if this is posted in the wrong room...
Is it possible for a PHP script to update the database every 'x' amount of minutes without someone actually viewing that page?
Is it possible for a PHP script to update the database every 'x' amount of minutes without someone actually viewing that page?
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Just a thought but u could bury it into the homepage of your website or whatever so your visitors do the work "blindly" for you.
They don't see what happened on the server when they requested your web page but your db gets updated (of course... you need enough visitors for it to be effective and you'd have to cut out all the errors in case of db failures and users getting 'mysql connect failed... bla bla bla')
Or you can just have a page open that refreshes or redirects to itself very x minutes
They don't see what happened on the server when they requested your web page but your db gets updated (of course... you need enough visitors for it to be effective and you'd have to cut out all the errors in case of db failures and users getting 'mysql connect failed... bla bla bla')
Or you can just have a page open that refreshes or redirects to itself very x minutes
There are pros and cons to putting the updating hidden inside your homepage.
Pro:
The DB only gets updated when it needs to be. There's no sense updating it every 5 minutes if no one's looking at the changes
Con:
Attaching the work to a page load will increase the load time of the page. Depending on how much data there is to crunch, and how busy the server is, this could add up.
One solution may be to just do the work for the first page load of the hour. So, if someone doesn't look at your page until 9:35, that's the page that does the work. Everyone else looking at the page that hour won't have to wait for the DB to be synched.
Pro:
The DB only gets updated when it needs to be. There's no sense updating it every 5 minutes if no one's looking at the changes
Con:
Attaching the work to a page load will increase the load time of the page. Depending on how much data there is to crunch, and how busy the server is, this could add up.
One solution may be to just do the work for the first page load of the hour. So, if someone doesn't look at your page until 9:35, that's the page that does the work. Everyone else looking at the page that hour won't have to wait for the DB to be synched.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.