#!/usr/bin/python3
# websockify, with Cache-Control: no-store on every file it serves. On its own it sends only
# Last-Modified, so a browser keeps noVNC's files for months on a guess, and answers a revalidation
# with 304 whenever the file on disk is older than the one cached. When the image's noVNC changes
# (Debian's 1.6 to Ubuntu's 1.3), a cached page then runs the other version's ui.js and fails as it
# starts. Over loopback, fetching every file each time costs nothing.
import sys

from websockify import websocketproxy

handler = websocketproxy.ProxyRequestHandler
end_headers = handler.end_headers


def no_store(self):
    self.send_header("Cache-Control", "no-store")
    end_headers(self)


handler.end_headers = no_store
sys.exit(websocketproxy.websockify_init())
