same-url.sjs (659B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ 4 5 "use strict"; 6 7 /** 8 * Serve a different content, each time it is loaded 9 */ 10 const contents = `console.log("Same url script #COUNTER");`; 11 12 function handleRequest(request, response) { 13 response.setHeader("Cache-Control", "no-store"); 14 response.setHeader("Content-Type", "application/javascript"); 15 16 let counter = 1 + parseInt(getState("counter") || 0); 17 setState("counter", "" + counter); 18 19 response.write(contents.replace(/COUNTER/g, counter)); 20 }