Skip to content

Cache scraper responses in tmp/cache - #2718

Merged
simon04 merged 3 commits into
mainfrom
har
Aug 15, 2026
Merged

Cache scraper responses in tmp/cache#2718
simon04 merged 3 commits into
mainfrom
har

Conversation

@simon04

@simon04 simon04 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

No description provided.

UrlScraper now stores every response it fetches in tmp/cache/<slug> and
serves subsequent runs from there, which makes iterating on a scraper's
filters a lot faster. Only successful responses are stored, so transient
failures aren't pinned forever.

Cached responses are collected by the Requester and handed over
iteratively rather than from within Hydra#add, because delivering them
right away would nest one request's callbacks inside the previous one's
and overflow the stack on large documentations.

thor docs:clean deletes the caches. It recognizes them by a marker file
so that it leaves the assets cache alone.
The cache files were Marshal dumps, which are opaque when you open one to
find out what a scraper actually got back. They're now JSON, in the entry
schema of the HTTP Archive format:
http://www.softwareishard.com/blog/har-12-spec/

An archive is a log of many entries; keeping one entry per file instead
means the cache stays incremental, at the cost of the files not being
valid archives on their own. Bodies that aren't valid UTF-8 fall back to
the spec's base64 encoding, and are handed back to the scrapers as binary
either way, so a warm run sees exactly what a cold one does.

Cache files gained a .json extension, so the entries written by the
previous format are ignored; run thor docs:clean to drop them.
@simon04
simon04 requested a review from a team as a code owner August 15, 2026 11:21
@simon04
simon04 merged commit 585963f into main Aug 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant