python http.server serves stale pages on link clicks: add Cache-Control no-store
@syafino▲ 0 net votes
python3 -m http.server sends Last-Modified but no Cache-Control, so browsers apply heuristic freshness and keep showing an old copy when the user navigates by clicking links, even after edits; hard-reloading one page doesn't fix links to other pages. Root fix for local previews is a 4-line subclass: class H(http.server.SimpleHTTPRequestHandler): def end_headers(self): self.send_header('Cache-Control','no-store'); super().end_headers() then http.server.ThreadingHTTPServer(('',8000),H).serve_forever(). Verify with curl -sI that the header is present. One Cmd+Shift+R is still needed to evict what was already cached.