Cache expiry missing Content Length
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start by tracing the middleware's cache-expiry check and the SourceMetadataLru handling described in the issue. Compare cachedImage.ImageCacheMetadata.ContentLength with sourceImageMetadata.ContentLength, then add or update coverage for replacing an image and loading it again within the 30-second cache lifetime.
Written by the indexing model from the issue text.
Description
Prerequisites
- I have written a descriptive issue title
- I have verified that I am running the latest version of ImageSharp.Web
- I have verified if the problem exist in both
DEBUGandRELEASEmode - I have searched open and closed issues to ensure it has not already been reported
ImageSharp.Web version
4.0.1
Other Six Labors packages and versions
4.1.1
Environment (Operating system, version and so on)
win11
.NET version
net10
Description
The Middleware is checking the CacheLastWriteTime and SourceLastWriteTime.
I think it should also check if the Content Length differs.
// Or has the source image changed since the image was last cached?
if (cachedImage.ImageCacheMetadata.ContentLength == 0 // Fix for old cache without length property
|| cachedImage.ImageCacheMetadata.CacheLastWriteTimeUtc <= (DateTimeOffset.UtcNow - this.options.CacheMaxAge)
|| cachedImage.ImageCacheMetadata.SourceLastWriteTimeUtc != sourceImageMetadata.LastWriteTimeUtc)
vs
if (cachedImage.ImageCacheMetadata.ContentLength == 0 // Fix for old cache without length property
|| cachedImage.ImageCacheMetadata.ContentLength != sourceImageMetadata.ContentLength
|| cachedImage.ImageCacheMetadata.CacheLastWriteTimeUtc <= (DateTimeOffset.UtcNow - this.options.CacheMaxAge)
|| cachedImage.ImageCacheMetadata.SourceLastWriteTimeUtc != sourceImageMetadata.LastWriteTimeUtc)
Btw. I hit an edge case eith the SourceMetadataLru cache. When you load the image, replace it and instantly load it (all in 30 seconds) --> This will result in old sourceImageMetadata because of the Lifetime of 30 seconds for the SourceMetadataLru
Steps to Reproduce
--
Images
No response
- Dominant language
- C#
- Stars
- 446
- Forks
- 104
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SixLabors/ImageSharp.Web
-
needs triage
Difficulty 4/5 3-5 days Newbie friendliness 45/100
SixLabors/ImageSharp.Web#401 · 5 comments ·
All issues in SixLabors/ImageSharp.Web
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·