Page 1 of 1

Time between two consecutive queries

Posted: Tue Jan 25, 2011 6:14 am
by Ludus
Hi there,
I made a script to login at which furthermore shows the selected data from the table using a query as a scrolling text, based on the Iframe and Javascript options (such as a short info-service). From the login scripts run Javascript that call other small PHP script that produces a query and then Javascript displays the resulting code in layer login skripte. All works beautifully if you use as a normal user, but I am afraid of the possibility that a some user holds down the whole time F5 to refresh page and so overloaded webserver and service crashes. 8O Therefore I would like to know how to skip making a query if the previous query was less than 10 seconds, something like a flood prevention or prevention of multiple consecutive Search queries on some forums if the interval is less than a defined time. Thank you.

Re: Time between two consecutive queries

Posted: Tue Jan 25, 2011 10:27 am
by AbraCadaver
You could start a session and each time the page loads to run the query you check the time against the time var you set in the session and see if it has been over 10 seconds. If so then run the query and update the session var with the new time, if not don't run the query.

However I don't think these reloads will really cause a problem.

Re: Time between two consecutive queries

Posted: Wed Jan 26, 2011 3:23 am
by Darhazer
Cache the results from the query (in a file or in memcached). Use cache expiration (if you cache in a file, check the modification timestamp of the file)