{"record":{"id":"acfdc6887483b66c","repo":"denoland/deno","slug":"response-status-must-not-be-206","errorCode":null,"errorMessage":"Response status must not be 206","messagePattern":"Response status must not be 206","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/cache/01_cache.js","lineNumber":160,"sourceCode":"    } else {\n      // Step 3.\n      innerRequest = toInnerRequest(new Request(request));\n    }\n    // Step 4.\n    const reqUrl = new URL(innerRequest.url());\n    if (reqUrl.protocol !== \"http:\" && reqUrl.protocol !== \"https:\") {\n      throw new TypeError(\n        `Request url protocol must be 'http:' or 'https:': received '${reqUrl.protocol}'`,\n      );\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","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/ext/cache/01_cache.js#L142-L178","documentation":"Step 6 of Cache.put(): a 206 Partial Content response must not be cached, because a later cache match would serve an arbitrary byte range instead of the full representation.","triggerScenarios":"Caching a response produced from a Range request (response.status === 206).","commonSituations":"Media players, resumable downloaders, and range-streaming clients that also try to populate the Cache API.","solutions":["Do not send a Range header on requests whose responses you intend to cache — fetch the full body.","Skip put() when response.status === 206."],"exampleFix":"// before\nawait cache.put(req, res); // res.status === 206\n// after\nif (res.status !== 206) {\n  await cache.put(req, res);\n}","handlingStrategy":"validation","validationCode":"if (response.status !== 206) {\n  await cache.put(request, response);\n}","typeGuard":null,"tryCatchPattern":"try { await cache.put(req, res); } catch (e) { if (e instanceof TypeError) { /* partial content: not cacheable */ } else throw e; }","preventionTips":["Do not send Range headers on requests whose responses will be cached.","Treat any non-200-299 (especially 206) response as non-cacheable in your caching wrapper."],"tags":["cache","http-status","range-request"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}