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.
Time between two consecutive queries
Moderator: General Moderators
Time between two consecutive queries
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.
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.
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.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Time between two consecutive queries
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.
However I don't think these reloads will really cause a problem.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Time between two consecutive queries
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)