Cache feed/llms.txt bodies, serve with content-hash ETags

Rendering every article per request is expensive. Bodies are now
RAM-cached keyed by the public base URL and cleared from
_invalidate_pages (the same hook that drops the page render cache on
any content/settings write). Responses carry a blake3 content-hash
ETag and answer 304, so polling feed readers revalidate cheaply;
matching page behavior, 304 revalidations are not recorded in
analytics.
This commit is contained in:
2026-09-23 07:30:32 +00:00
parent 9ff22016d1
commit 2aed176c9e
3 changed files with 70 additions and 34 deletions
+7 -2
View File
@@ -171,11 +171,16 @@ _render_gen = 0
def _invalidate_pages() -> None:
"""Drop cached page bodies and bump the render generation (ETags);
any content change also re-runs translation dispatch."""
"""Drop cached page bodies (and the feed/llms.txt export bodies) and
bump the render generation (ETags); any content change also re-runs
translation dispatch."""
global _render_gen
_render_gen += 1
_cached_body.cache_clear()
# Local import: pagerite.feeds imports this module.
from pagerite import feeds
feeds._cached_feed.cache_clear()
dispatcher.schedule()