CacheConfig.CacheTTL is configured but never read — cached variants never expire #69
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Verified against
mainat61f42e6.CacheConfig.CacheTTL(internal/imgcache/cache.go:28) is populated in production wiring atinternal/handlers/handlers.go:66withDefaultCacheTTL = 24 * time.Hour(internal/imgcache/module.go:7), and set in six test fixtures. It is never read: grep forconfig.CacheTTL/c.config.CacheTTLacross the tree returns only assignments, no uses.Only
NegativeTTLis actually enforced (cache.go:214), andCleanExpired(cache.go:285-295) purges only thenegative_cachetable.So the "24 hour cache TTL" implied by the constant does not exist: a cached variant is served indefinitely, and a source image that changes at the origin is never re-fetched. For an image proxy that is a correctness question, not just a tidiness one — there is currently no mechanism by which updated upstream content ever reaches a client.
Definition of done
Decide which of these is intended, then make the code say so:
CacheTTLare treated as misses and re-fetched/revalidated. Consider conditional revalidation using upstreamLast-Modified/ETag(currently captured nowhere — see the related headers issue) rather than unconditional re-fetch, so a TTL expiry does not mean a guaranteed full re-download.Either way:
config.example.ymland README.make checkgreen.Recommendation: (a) — an image proxy that can never pick up an upstream change is surprising, and #51's eviction is size-driven, not freshness-driven, so it does not cover this.
Coordination
Touches
internal/imgcache/cache.go, which PR #55 also changes substantially. Do this after #55 merges to avoid a conflict, and check whether #55's accounting timestamps (last_accessed_at) give a cheaper way to implement (a).