javascriptnode.jsresourcesfile-monitoring

Node.js: how to poll a web resource for change?


Using node.js how do I poll a web resource (eg. example.org/data.json) for change in a asynchronous way so I can notify the clients whenever a certain resource has changed ?

I'm looking for a lib or at least a somewhat more elegant way to archive this rather than downloading the file myself, calculating and comparing the hashes every few seconds.

Everything I found so far is using inotify or fswatch under the hood so it cant be used for non local files.


Solution

  • You could try the Last-Modified Header field, if this is supported by the web resource.