Send cache headers so updates reach visitors on a normal reload

#3
by lewtun HF Staff - opened
Hugging Face Agent Swarms Research org

What

Cache headers for the demo's files. server.py replaces python -m http.server: the page, scripts and data (index.html, worker.js, pybot_web.py, tree.json) get Cache-Control: no-cache; the bot bundle gets immutable, the fonts one day.

Why

After #2 was merged, Lewis's browser kept the old index.html and paired it with the new tree.json, so file links had the new commit but no line numbers. http.server sends no Cache-Control, so browsers may reuse a page heuristically after an update.

How

  • no-cache still lets browsers keep a copy, but they check it on every load. An unchanged file costs a 304 (http.server already handles If-Modified-Since).
  • The bundle can be cached for good because its name changes with every build (pybot-<sha12>-<hash>.zip).
  • Dockerfile runs server.py (port 7860 as before; HOST/PORT can be overridden for local tests). README updated.

Testing

Served the live files locally with server.py: the headers are as above, and an unchanged index.html revalidates with 304. In headless Chromium the demo loads and answers, and "Hi, I'm Sam" links to chat.py#L14163-L14285, with no page errors.

๐Ÿค– Generated with Claude Code

lewtun changed pull request status to merged

Sign up or log in to comment