Use Rack::Static to serve (empty) mirror.js
Add middleware to insert <script> tag
Install Thin
Install Faye
Insert Faye JavaScript into page
Synchronise scroll positions
Synchronise current URLs on link click
Maintain current protocol, hostname and port when navigating
Only navigate to internal links
Rewrite redirect responses
Send scroll and navigate events on each page load
Override window.history.pushState to publish navigation events
Cache the current scroll position and URL on the server
Republish the current scroll position and URL during handshake

This makes the controlling browser proactively freshen the server state,
instead of allowing the server to send stale state to mirroring browsers
until a user interaction causes the controlling browser to send a message.
Send the current scroll position and URL in subscription messages
Restore state when subscription messages are received
Insert Apple-specific <meta> tag into each page

This allows the proxied site to run as a full-screen web app on iOS.