#!/usr/bin/env python3 """Dev server that refuses to cache anything. `python3 -m http.server` sends Last-Modified, and browsers cache ES modules on it hard enough that a reload can serve a stale js/app.js against a fresh index.html. That failure is silent and points nowhere near its cause: the new knobs appear in the markup, nothing wires them, no error is raised, and the symptom reads as "the feature you just added does not work". """ import sys from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer class NoCache(SimpleHTTPRequestHandler): def end_headers(self): self.send_header('Cache-Control', 'no-store, must-revalidate') self.send_header('Expires', '0') super().end_headers() def log_message(self, fmt, *args): if '304' not in fmt % args: super().log_message(fmt, *args) if __name__ == '__main__': port = int(sys.argv[1]) if len(sys.argv) > 1 else 8777 print(f'http://127.0.0.1:{port} (no-store)') ThreadingHTTPServer(('127.0.0.1', port), NoCache).serve_forever()