Add an opt-in image cache to capture#51
Merged
Merged
Conversation
Capturing a site once per viewport per parallel context re-fetches every
image from the origin each time, which can swarm a server — especially
uncached local or staging environments. The new "imageCache" option in
reglance.json answers repeat image requests locally instead.
No proxy server and no URL rewriting: image requests are intercepted via
the existing context.route() hook and fulfilled from a disk cache under
.reglance/image-cache/. The cache key is the full request URL, query
string included, so CDN resize variants stay distinct. Simultaneous
requests for the same URL share a single origin fetch. Only GET image
requests are cached — documents, CSS, and JS always load from the
origin — and only 2xx responses are stored, so a broken image stays
broken in the capture.
"imageCache": true gives a per-run cache cleared at the start of every
capture, so repeat traffic drops with no risk of a stale image masking a
real change between control and compare runs. { "persist": true } keeps
the cache across runs for rapid re-capture loops, with --fresh-images to
clear it on demand.
Co-Authored-By: Claude Fable 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an opt-in
imageCacheoption toreglance.jsonso capture runs answer repeat image requests from a local disk cache instead of re-fetching every image from the origin once per viewport per parallel context.How
No proxy server and no URL rewriting. Image requests are intercepted with the same
context.route()hook already used forblockHostsand fulfilled from.reglance/image-cache/, so nothing in the DOM, the HTML snapshots, or the screenshots changes:photo.jpg?w=400vs?w=800) are distinct entries. Coverssrcset,<picture>, and CSS background images automatically since interception happens at the network layer.The default per-run mode is cleared at the start of every capture, so there is zero risk of a stale cached image masking a real origin change between control and compare runs. Persistence is a conscious opt-in for rapid re-capture loops, with
--fresh-imagesas the escape hatch (documented trade-off in the README).Verification
--fresh-images: cache cleared and re-seeded, one fetch per URL again.🤖 Generated with Claude Code