{"record":{"id":"f31003201f50bb59","repo":"gofiber/fiber","slug":"cache-failed-to-delete-stale-vary-manifest-q-w","errorCode":null,"errorMessage":"cache: failed to delete stale vary manifest %q: %w","messagePattern":"cache: failed to delete stale vary manifest %q: %w","errorType":"http","errorClass":null,"httpStatus":500,"severity":"warning","filePath":"middleware/cache/cache.go","lineNumber":633,"sourceCode":"\t\t\tif e != nil {\n\t\t\t\tif err := deleteKey(reqCtx, key); err != nil {\n\t\t\t\t\tif cfg.Storage != nil {\n\t\t\t\t\t\tmanager.release(e)\n\t\t\t\t\t}\n\t\t\t\t\treturn fmt.Errorf(\"cache: failed to delete cached response for key %q: %w\", maskKey(key), err)\n\t\t\t\t}\n\t\t\t\tmux.Lock()\n\t\t\t\tremoveHeapEntry(key, e.heapidx)\n\t\t\t\tif cfg.Storage != nil {\n\t\t\t\t\tmanager.release(e)\n\t\t\t\t}\n\t\t\t\te = nil\n\t\t\t\tmux.Unlock()\n\t\t\t}\n\n\t\t\tif !cfg.DisableVaryHeaders && hasVaryManifest {\n\t\t\t\tif err := manager.del(reqCtx, manifestKey); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"cache: failed to delete stale vary manifest %q: %w\", maskKey(manifestKey), err)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tc.Set(cfg.CacheHeader, cacheUnreachable)\n\t\t\treturn nil\n\t\t}\n\n\t\tshouldStoreVaryManifest := !cfg.DisableVaryHeaders && len(varyNames) > 0\n\t\tif !cfg.DisableVaryHeaders && len(varyNames) > 0 {\n\t\t\tif key == baseKey {\n\t\t\t\tkey += buildVaryKey(varyNames, &c.Request().Header, canonical)\n\t\t\t}\n\t\t} else if !cfg.DisableVaryHeaders && hasVaryManifest {\n\t\t\tif err := manager.del(reqCtx, manifestKey); err != nil {\n\t\t\t\treturn fmt.Errorf(\"cache: failed to delete stale vary manifest %q: %w\", maskKey(manifestKey), err)\n\t\t\t}\n\t\t}\n","sourceCodeStart":615,"sourceCodeEnd":651,"githubUrl":"https://github.com/gofiber/fiber/blob/a105acad6c1e4576a77f01e02973f67e962bb58d/middleware/cache/cache.go#L615-L651","documentation":"Returned from the response path when, after purging an uncacheable entry (private/no-cache/Vary:*), the cache tries to also delete the associated Vary manifest and manager.del fails. The Vary manifest maps the base key to its vary-axis keys; leaving it stale would cause future requests to compute keys against an obsolete vary set, so the failure is surfaced.","triggerScenarios":"cfg.DisableVaryHeaders is false and the response path determined hasVaryManifest is true (a manifest was previously stored for this base key); the storage Delete for the manifest key fails. The masked manifest key is included for correlation.","commonSituations":"Storage backend transient failure during a vary-axis change; multi-instance deployment racing on the same base key; manifest key namespace clash; storage under pressure during vary-heavy traffic (e.g. content negotiation).","solutions":["Diagnose the wrapped delete error against the storage backend.","Ensure the manifest key namespace is exclusive to the cache (no other writer uses the same prefix).","If vary churn is high, audit upstream Vary usage to reduce axis count.","Right-size storage pool and add reconnect/backoff.","Reproduce with vary logging enabled to correlate manifest keys."],"exampleFix":"// before: storage delete occasionally times out under load\n\n// after: bound the storage client and add retries at the client level\ncfg := cache.Config{Storage: storageWithRetries, DisableVaryHeaders: false}","handlingStrategy":"validation","validationCode":"// Ensure the cache manifest key namespace is exclusive and deletes work.\nfunc probeManifestDelete(s fiber.Storage, ns string) error {\n    k := ns + \":vary:probe\"\n    if err := s.Set(k, []byte(\"{}\"), time.Second); err != nil { return err }\n    return s.Delete(k)\n}","typeGuard":null,"tryCatchPattern":"app.Use(func(c fiber.Ctx) error {\n    err := c.Next()\n    if err != nil && isCacheManifestDeleteErr(err) {\n        // manifest cleanup failed; future vary-key computation may be stale until next purge\n        return nil\n    }\n    return err\n})","preventionTips":["Reserve a dedicated key prefix for the cache (no foreign writers).","Keep vary axis count low to reduce manifest churn.","Add storage delete monitoring specific to the cache namespace.","Reproduce with vary logging enabled to correlate manifest keys."],"tags":["cache","storage","delete","vary","manifest"],"backgroundTag":null,"analyzedSha":"a105acad6c1e4576a77f01e02973f67e962bb58d","analyzedAt":"2026-08-11T17:33:26.942Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}