WebVeteran / CFup

A file upload progress indicator written in ColdFusion and Ajax (no Flash or Java)
http://www.webveteran.com/blog/index.php/category/web-related-software/cfup/
Other
3 stars 2 forks source link

Poll Speed #2

Open dogzipp opened 15 years ago

dogzipp commented 15 years ago

Would it be possible to have the JS not poll my server with 100 ajax requests a minute? hehe.

Perhaps some kind of delay can be put on the JS, so the actually ajax polling could be done once every second or something like that.

WebVeteran commented 15 years ago

Polling is necessary to get the uploaded file size in near real time. But perhaps a throttle setting would be a nice addition.

dogzipp commented 15 years ago

I understand. I am just trying to avoid getting hammered with so many request, sometimes about 10 per second. One every second or two, could still be near real-time and be healthier for the web server.

As far as I understand, there's really no "pause" command on Javascript, so a trick would need to be used to cause the script to pause a while between ajax requests.

WebVeteran commented 15 years ago

There is a pause built in. It's two-part.

1) after the previous ajax call is returned, the counter animates (lasts .2s) 2) after the animation, the next call is done ( in essence, a .2s timer)

That 0.2s should be a setting instead of hard-coded. Then, you'd be able to have a 1s timer instead.