Ping (checking connection)
This is especially important for mobile applications that have and offline and online mode. The mobile device might say it is online when connected to wifi behind a firewall (e.g. at an airport lounge), however it will not be able to connect to the API endpoint so it is effectively offline. Use PING to see if you can get to the API endpoint.
Best Practice
Try to avoid continually pinging the endpoint. Instead set event listeners for all events that might indicate a change in connectivity status (window: online/offline, window.applicationCache:error/downloading, etc) and use a PING inside the handler code to confirm if the endpoint can be reached or not.
GET /api/rest/ping
Response:
HTTP/1.1 200 OK Server:Â nginx Date: Tue, 06 Jan 2015 19:22:26 GMT Content-type: text/json Transfer-encoding: chunked Connection: close
{"response":"pong","timestamp":1420572146,"datetime":"2015-01-06T19:22:26+0000"}