1

Is there a possibility to monitor changes of file on some server without downloading it? I read about chokidar module but I cant find anything about my issue I believe there is the way to watch some headers or smth like this Maybe here is someone who have solved similar issue?

Jesus_Maria
  • 1,137
  • 5
  • 14
  • 24
  • Your file is in the same server as your NodeJS app ? – Mohamed Amjad LASRI Jun 02 '15 at 13:04
  • @MohamedAmjadLASRI No its "somewhere" – Jesus_Maria Jun 02 '15 at 13:22
  • Even if you watch just headers you're still downloading it, or at least some part of it. And then to check for changes, you'll have to store the previous content to compare it against. – laggingreflex Jun 02 '15 at 14:05
  • chowkidar or other file watchers are simply wrappers for node's core [fs.filewatch](https://nodejs.org/docs/latest/api/fs.html#fs_fs_watchfile_filename_options_listener) and [the way it works](http://stackoverflow.com/questions/5394620/node-js-how-does-fs-watchfile-work) doesn't apply to remote files – laggingreflex Jun 02 '15 at 14:07

2 Answers2

1

You can check Last-Modified and/or E-tag http headers.

var http = require('http');
var options = {method: 'HEAD', host: 'stackoverflow.com', port: 80, path: '/'};
var req = http.request(options, function(res) {
    console.log(res.headers);
  }
);
req.end();
Louay Alakkad
  • 7,132
  • 2
  • 22
  • 45
-1

Yes you can "watch" files using NodeJS.

How to do it:

There is several NodeJS modules allowing that. Take a look at watchr for example. You can "watch" a file or a directory using it.