I think a lot of people are using MQTT now? You can then run an MQTT server on the Pi, and could communicate with from webpages using MQTT over websockets - it avoids having to have all the state storing and constant polling, as the MQTT server handles pushing messages as and when it's required.
Are you able to expose the Pi itself to the outside world? Even if you're not you could put an MQTT server on your web server and work that way or maybe use a third party server like Adafruit's one?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I think a lot of people are using MQTT now? You can then run an MQTT server on the Pi, and could communicate with from webpages using MQTT over websockets - it avoids having to have all the state storing and constant polling, as the MQTT server handles pushing messages as and when it's required.
Are you able to expose the Pi itself to the outside world? Even if you're not you could put an MQTT server on your web server and work that way or maybe use a third party server like Adafruit's one?