fix: CacheableResponse should only download file when needed#2035
Merged
thomas-zahner merged 2 commits intolycheeverse:masterfrom Feb 11, 2026
Merged
fix: CacheableResponse should only download file when needed#2035thomas-zahner merged 2 commits intolycheeverse:masterfrom
thomas-zahner merged 2 commits intolycheeverse:masterfrom
Conversation
Fixes https://www.github.com/lycheeverse/lychee/issues/2034 This changes the CacheableResponse's text field to be an Option. By default, responses will be cached without the body text. Cached responses can be "upgraded" to include the body if fragments need to be checked inside that URL. Once upgraded, the response with body will be cached for future fragment checks. This is not a very intelligent fix to the issue, I don't love passing `needs_body: bool` everywhere. But it does work and it's not very invasive. Note that this caching of body text is slightly redundant, because FragmentChecker already caches its own set of anchors within each URL. But it could be useful if the text is needed for other things in future (recursion???).
Member
|
@katrinafyi Thank you for the PR! I see no issues with it apart from the test that could be made more precise.
I think this approach is totally fine. |
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.
Fixes #2034
This changes the CacheableResponse's text field to be an Option. By default, responses will be cached without the body text so they can be checked quickly even if the file is large. Cached responses can be "upgraded" to include the body if fragments need to be checked inside that URL. Once upgraded, the response with body will be cached for future fragment checks.
This is not a very intelligent fix to the issue, I don't love passing
needs_body: booleverywhere. But it does work and it's not very invasive.Note that this caching of body text is slightly redundant, because FragmentChecker already caches its own set of anchors within each URL. But it could be useful if the text is needed for other things in future (recursion???).