{"record":{"id":"4f4cbf1d9ac598d6","repo":"denoland/deno","slug":"vary-header-must-not-contain","errorCode":null,"errorMessage":"Vary header must not contain '*'","messagePattern":"Vary header must not contain '\\*'","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/cache/01_cache.js","lineNumber":169,"sourceCode":"      );\n    }\n    if (innerRequest.method !== \"GET\") {\n      throw new TypeError(\"Request method must be GET\");\n    }\n    // Step 5.\n    const innerResponse = toInnerResponse(response);\n    // Step 6.\n    if (innerResponse.status === 206) {\n      throw new TypeError(\"Response status must not be 206\");\n    }\n    // Step 7.\n    const varyHeader = getHeader(innerResponse.headerList, \"vary\");\n    if (varyHeader) {\n      const fieldValues = StringPrototypeSplit(varyHeader, \",\");\n      for (let i = 0; i < fieldValues.length; ++i) {\n        const field = fieldValues[i];\n        if (StringPrototypeTrim(field) === \"*\") {\n          throw new TypeError(\"Vary header must not contain '*'\");\n        }\n      }\n    }\n\n    // Step 8.\n    if (innerResponse.body !== null && innerResponse.body.unusable()) {\n      throw new TypeError(\"Response body is already used\");\n    }\n\n    const stream = innerResponse.body?.stream;\n    let rid = null;\n    if (stream) {\n      const resourceBacking = getReadableStreamResourceBacking(\n        innerResponse.body?.stream,\n      );\n      if (resourceBacking) {\n        rid = resourceBacking.rid;\n      } else {","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/cache/01_cache.js#L151-L187","documentation":"Cache.put(request, response) parses the response's Vary header (spec step 7) and rejects the operation if any field value is '*'. Vary: * means the response depends on unspecified request headers, making it uncacheable by design.","triggerScenarios":"The origin returns `Vary: *` (or `Vary: Accept, *`) and the code calls cache.put with that response; the check splits the header on commas and trims each field before comparing to '*'.","commonSituations":"Caching third-party API responses where the origin sets Vary: * to defeat shared caches; CDNs that aggregate Vary values.","solutions":["Check `response.headers.get(\"vary\")` for a '*' entry before calling cache.put and skip caching","If you control the origin, send a concrete Vary list (e.g. 'Accept-Encoding') instead of '*'","Store such responses outside the Cache API if you really need them"],"exampleFix":"// before\nawait cache.put(req, res); // res has Vary: *\n\n// after\nconst vary = (res.headers.get(\"vary\") ?? \"\").split(\",\").map((s) => s.trim());\nif (!vary.includes(\"*\")) await cache.put(req, res);","handlingStrategy":"validation","validationCode":"function hasVaryWildcard(res: Response): boolean {\n  return (res.headers.get(\"vary\") ?? \"\")\n    .split(\",\")\n    .some((f) => f.trim() === \"*\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Inspect the Vary header before cache.put","Fix origins you control to send concrete Vary lists","Treat Vary: * responses as explicitly uncacheable"],"tags":["cache-api","http-headers","vary","validation"],"backgroundTag":"vary-header-wildcard","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}