简体   繁体   中英

How to get a track of server side updates client side?

The scenario is that I am having a piece of code written in Javascript that keeps refreshing after a short interval of time and keep matching with a file on the server side and if there is a change in the file on the server side it downloads the updated file. But because it keep refreshing all the time so it may create a huge traffic on the server on later run.

So i want to know that is there any kind of mechanism here (like push notifications i have heard though not sure about it) that can give a notification to the client when the file on the server side updates? So that client side may be free from creating unnecessary requests.

Given that my server side code is written in Java.

I think what you're looking for is websockets. These enable two way communication between a server and a (web) client. This way, you can send the push notifications to your client.

There is some more information here about websockets (the client side) and here is the java documentation.

Consider researching Websockets and Server-sent events . I have not used any of them with Java but I'm sure that you can find a nice library.

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