Flying memes

NoQueue: an experiment with Service Worker and The Physical Web

Lately I found myself spending a considerable amount of time playing with Service Worker. This is an insanely interesting new HTML5 feature that basically allow us to define a JS file as a ‘proxy’ between the actual page and the server. The so defined Javascript file is then marked as Service Worker for the current domain (or a part of it) and this is where the magic begin

A Service Worker has two main features (but more to come). The first is that it can intercepts all the HTTP requests leaving the controlled domain and choose what to do with them, this alone is huge: by routing all the requests to a local cache you can easily implement an offline experience, or you can enrich a JSON response with a previously cached Handlebars template, and so on.

The second, and at least equally awesome, feature is that a properly configured Service Worker can receive Push Notification, even if the user is not actively browsing the controlled page, and, on mobile, even if the user has closed the browser!

Now, mix this HTML5 feature with The Physical Web and you have a very explosive mixture in your hand, you can have a beacon that emit an URL that points to a page that install a Service Worker and, later, you can receive a Push Notification from the service you basically subscribed by simply double-tapping on the beacon URL.

On this idea I built NoQueue (github: a real life queue management system that allows a user to subscribe to a Queue and being notified as soon as it’s his turn to be served.

Here’s a short video showcasing all the workflow:

Tags: ,