Simple HTTP Change Detector
This is a minimal app that requests the target page's headers to get the page's
content-length and compares it to a previously known value to see whether the page has changed. This is done in order to limit the amount of information requested and received from the server thereby hopefully decreasing stress on the server from constant pinging.
How to use
$ git clone https://github.com/jssolichin/simple-http-change-detector
npm install(to install nodemailer for notification).
- Edit app.js and change
- Set up task scheduler (refer to next section).
Change Detection Interval
For seperation of concerns, the app itself only runs once and requires a task scheduler. Every OS comes with their own task scheduler and there is no need to add additional bloat that will not be as robust as the built-in scheduler. Below are information on each system's task scheduling mechanism.
- Windows' Task Scheduler
- Mac's LaunchD
- UNIX/Linux' Cron (My own set up at the end) (Mac users can technically use this as well, but it is discouraged in place of launchd)
If you have your own method of task scheduling, feel free to use it!
For notification, the app utilizes nodemailer. Nodemailer allows the app to send email. Please refer to nodemailer for a more extensive documentation. A list of common services (e.g. gmail, yahoo, etc.) are available here for easy setting up.
Note: Email can be used to send SMS
$ crontab -e
Add the following line at the end for a 5 minute interval detection from 7am to 2am
*/5 0-2,7-23 * * * user /usr/bin/nodejs /home/pinger/app.js
Cron syntax: minutes, hour, day of month, month, day of week, user, command.
So we are saying:
*/5means every 5 minutes (*/ means interval rather than that number)
0-2,7-23means every hour that starts with 0-2 and 7-23 (aka 7 a.m. to 2 a.m.)
*every day of the month
*every day of the week
usermeans run the command with the user called user
/usr/bin/nodejsis the location of nodejs
/home/pinger/app.jsis the location of the app