Concepts

Public GET cache allowlist (pattern)

Try the free JavaScript compiler

Editorial pure-logic pattern: store only successful responses for explicitly allowed public GET paths. Not a built-in API.

Formal Syntax & Structure

javascript syntaxjavascript
shouldCache(method, path, ok)

Return Value

boolean

Editorial pure-logic pattern: store only successful responses for explicitly allowed public GET paths. Not a built-in API.

Working Example

Example Snippetjavascript
(async () => {const allow=new Set(["/assets/app.v2.js"]);const shouldCache=(method,path,ok)=>method==="GET"&&allow.has(path)&&ok;console.log(shouldCache("GET","/assets/app.v2.js",true),shouldCache("POST","/assets/app.v2.js",true),shouldCache("GET","/private",true));})()
JavaScript Reference