开发者

What are some good strategies for checking for updates through a webpage? [closed]

开发者 https://www.devze.com 2022-12-16 00:45 出处:网络
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing
Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 3 years ago.

Improve this question

Are any of you aware of some good strategies for checking for updates on a webserver?

I'm thinking a long the lines of the facebook startpage and stackove开发者_运维问答rflow questionviewing here. However, I need to load the new data without reloading the whole page.

Currently, I think of having a javascript "timer" working through the pages lifetime, polling the webserver if any new data has been entered. Our target scope is ~2000 browsers doing this at the same time, so I really don't want a full-scale equality checking of the old data vs. the new data.

I'm using ASP.Net, so I thought a good way to achieve this would be to store a "last datapolling time" variable in the session variable, and then update that time if new data has been entered that this client should receive. Does this sound feasible to you?

I'm not sure I explained myself fully here, so please ask any questions you might have in the comments, and I'll update this question :)

Thanks in advance


I'm not familiar with .Net, but I can tell you how I would solve it with Java Servlets. The solution in .Net should be similar.

I would create a Servlet as a REST ressource with a certain URL and a lastModified method that answers depending on the content state (and current user). The client would poll with HTTP HEAD the current state of the resource. Only if it was modified since the last request, the client would send a GET request. If the server knows how long the resource will at least remain unmodified, he could send an expires header. The client would then begin to poll after expiration time.


You can't use a push interface to update your webpage. So you are going to have to pull. Just hit the server with Ajax and check for updates.


You can cache this information somewhere so that you aren't doing a full scale equality check every time you look up the new data. You'll need to store a last update time somewhere on your server and if that is newer than the clients time you will know that there is new data to be loaded


Polling the server and using AJAX to update some content is probably the most common solution, but you actually can use a push to update your webpage. It's certainly more exotic, but you can use Silverlight's duplex communication to push content to a page.

Tomasz Janczuk has developed a stand-alone javascript library that will handle the client end of the Silverlight functionality.

He's even got an article discussing the scale-out implications on web farms - http:// tomasz.janczuk.org/2009/09/scale-out-of-silverlight-http-polling.html (delete the space - my newbie status prevents me from linking more than once in an answer). He's done some great work that might help you setup a nice push model for your content.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号