简体   繁体   中英

Limit curl fetches / refreshes per minute

How would i go about limiting a page refresh and thus curl fetch to one per minute (or 5, etc)? An example would be to pull the price of an item on Amazon, the user is limited to one fetch per minute, after that minute is up he can refresh for an updated fetch, until then he is told to try again in a minute.

You can store the last fetch timestamp in session for the user. When new refresh requested you need to verify the previous time stamp difference with latest and see the difference is fine or needs to wait.

Just implement a strict set of caching rules - if you get a request for an item, check if its in the cache and not more than N seconds old - if its older, fetch a new one, if its younger send back the cached one. Require a valid session and keep the timestamp of the last accepted request (whether supplied from cache or source). If the user requests additional content before M seconds have expired, then tell them to try later.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM