The desktop failed to start in a browser that had cached noVNC 1.6 from the Debian desktop image: its vnc.html, which has no clipboard Clear button, ran the Ubuntu image's 1.3 ui.js, which wires one up and threw "Cannot read properties of null". websockify sends only Last-Modified, so browsers cache noVNC on a guess, and it answers a revalidation with 304 when the file on disk is older than the copy. Serve noVNC through websockify-no-store, which adds Cache-Control: no-store to every response, and from /novnc/ rather than /, so no browser holds a stale copy at the paths the desktop now uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
780 B
Python
22 lines
780 B
Python
#!/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())
|