#!/usr/bin/env python3 """Dev server for bin/web with caching disabled. The browser aggressively caches .wasm/.js, and a plain reload (Ctrl+R) will happily serve a stale module while the page *looks* freshly loaded — which makes "did my rebuild take effect?" impossible to answer and sends you chasing bugs that were already fixed. Everything here is served no-store so a rebuild is always what you get, regardless of how the page is reloaded. """ import http.server, socketserver, sys PORT = int(sys.argv[1]) if len(sys.argv) > 1 else 8080 class NoCache(http.server.SimpleHTTPRequestHandler): def end_headers(self): self.send_header("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0") self.send_header("Pragma", "no-cache") self.send_header("Expires", "0") super().end_headers() def log_message(self, fmt, *args): pass # quiet; the build script is the interesting output socketserver.TCPServer.allow_reuse_address = True with socketserver.TCPServer(("", PORT), NoCache) as httpd: print(f"serving bin/web on http://localhost:{PORT}/rspektrum.html (no-store)") httpd.serve_forever()