browser_toolbox_options_disable_cache.sjs (949B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 function handleRequest(request, response) { 5 const Etag = '"4d881ab-b03-435f0a0f9ef00"'; 6 const IfNoneMatch = request.hasHeader("If-None-Match") 7 ? request.getHeader("If-None-Match") 8 : ""; 9 10 const guid = "xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx".replace( 11 /[xy]/g, 12 function (c) { 13 const r = (Math.random() * 16) | 0; 14 const v = c === "x" ? r : (r & 0x3) | 0x8; 15 16 return v.toString(16); 17 } 18 ); 19 20 const page = "<!DOCTYPE html><html><body><h1>" + guid + "</h1></body></html>"; 21 22 response.setHeader("Etag", Etag, false); 23 24 if (IfNoneMatch === Etag) { 25 response.setStatusLine(request.httpVersion, "304", "Not Modified"); 26 } else { 27 response.setHeader("Content-Type", "text/html; charset=utf-8", false); 28 response.setHeader("Content-Length", page.length + "", false); 29 response.write(page); 30 } 31 }