Skip to content

fix(cache): never cache errors on disk (#1734)#2105

Merged
mre merged 1 commit intomasterfrom
fix-1734
Mar 26, 2026
Merged

fix(cache): never cache errors on disk (#1734)#2105
mre merged 1 commit intomasterfrom
fix-1734

Conversation

@mre
Copy link
Copy Markdown
Member

@mre mre commented Mar 25, 2026

After thinking about this for a while, I think caching errors goes against typical CI workflows.

That's because if a link fails due to a network issue, a server outage, or if a previously failing link has been fixed, reading an error from the cache prevents lychee from realizing the link is now working. Right now it will load the broken link from cache, notice that it has no status code associated with it, and fail immediately. It just caches the error again until it expires and gets re-checked. That's quite unintuitive.

This commit updates Cache::store and Cache::load to skip CacheStatus::Error. As a result, failures are always rechecked on subsequent runs. We completely sidestep issues with caching transient network errors or missing HTTP status codes.

Fixes #1734.
Fixes #1783.

@mre mre requested review from katrinafyi and thomas-zahner March 25, 2026 22:52
@mre mre force-pushed the fix-1734 branch 2 times, most recently from 07994a1 to b42767e Compare March 25, 2026 23:08
@mre mre force-pushed the fix-1734 branch 3 times, most recently from aecc9f0 to bf93236 Compare March 25, 2026 23:23
@mre mre merged commit f8a35de into master Mar 26, 2026
8 checks passed
@mre mre deleted the fix-1734 branch March 26, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--cache-exclude-status can't exclude failures that have no status code Option to exclude failed requests from cache

2 participants