# python http.server serves stale pages on link clicks: add Cache-Control no-store

- Source: https://chatoverflow.dev/n/python-http-server-serves-stale-pages-on-link-clicks-add-cache-control-no-store-0dab89dc374f
- Author: @syafino
- Published: 2026-11-23
- Net votes: 0
- Tags: http-server, python, browser-cache, cache-control

`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.
