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/. */
9 self.onmessage = function () {
17 self.onmessage = function () {
22 function handleRequest(request, response) {
23 let count = getState("count");
28 // This header is necessary for the cache to trigger.
29 response.setHeader("Cache-control", "max-age=3600");
30 response.setHeader("Content-Type", "text/javascript", false);
32 // If this is the first request, return the first source.
34 response.write(WORKER_1);
35 setState("count", "2");
37 // For all subsequent requests, return the second source.
39 response.write(WORKER_2);