fix: align cache controls with config
Remove unused head-check config, make TTL overrides explicit, and tighten revalidation to avoid stale cache behavior.
This commit is contained in:
@@ -37,7 +37,14 @@ func cachePolicy(_ *hooks.RequestContext, locatorPath string, current hooks.Cach
|
||||
// 索引类(Release/Packages/Contents)需要 If-None-Match/If-Modified-Since 再验证。
|
||||
if strings.HasSuffix(clean, "/release") ||
|
||||
strings.HasSuffix(clean, "/inrelease") ||
|
||||
strings.HasSuffix(clean, "/release.gpg") {
|
||||
strings.HasSuffix(clean, "/release.gpg") ||
|
||||
strings.HasSuffix(clean, "/packages") ||
|
||||
strings.HasSuffix(clean, "/packages.gz") ||
|
||||
strings.HasSuffix(clean, "/packages.xz") ||
|
||||
strings.HasSuffix(clean, "/sources") ||
|
||||
strings.HasSuffix(clean, "/sources.gz") ||
|
||||
strings.HasSuffix(clean, "/sources.xz") ||
|
||||
strings.Contains(clean, "/contents-") {
|
||||
current.AllowCache = true
|
||||
current.AllowStore = true
|
||||
current.RequireRevalidate = true
|
||||
|
||||
@@ -11,13 +11,14 @@ type StrategyOptions struct {
|
||||
// ResolveStrategy 将模块的默认策略与 hub 级覆盖合并。
|
||||
func ResolveStrategy(meta ModuleMetadata, opts StrategyOptions) CacheStrategyProfile {
|
||||
strategy := meta.CacheStrategy
|
||||
if strategy.TTLHint > 0 && opts.TTLOverride > 0 {
|
||||
strategy.TTLHint = opts.TTLOverride
|
||||
}
|
||||
if opts.ValidationOverride != "" {
|
||||
strategy.ValidationMode = opts.ValidationOverride
|
||||
}
|
||||
return normalizeStrategy(strategy)
|
||||
strategy = normalizeStrategy(strategy)
|
||||
if opts.TTLOverride > 0 {
|
||||
strategy.TTLHint = opts.TTLOverride
|
||||
}
|
||||
return strategy
|
||||
}
|
||||
|
||||
func normalizeStrategy(profile CacheStrategyProfile) CacheStrategyProfile {
|
||||
|
||||
Reference in New Issue
Block a user