file_cache_splitting_isloaded.sjs (907B)
1 /* 2 Helper Server - 3 Send a Request with ?queryResult - response will be the 4 queryString of the next request. 5 6 */ 7 // small red image 8 const IMG_BYTES = atob( 9 "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12" + 10 "P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" 11 ); 12 13 function handleRequest(request, response) { 14 // avoid confusing cache behaviors 15 response.setHeader("Cache-Control", "no-cache", false); 16 17 // save the object state of the initial request, which returns 18 // async once the server has processed the img request. 19 if (request.queryString.includes("wait")) { 20 response.processAsync(); 21 setObjectState("wait", response); 22 return; 23 } 24 25 response.write(IMG_BYTES); 26 27 // return the result 28 getObjectState("wait", function (queryResponse) { 29 if (!queryResponse) { 30 return; 31 } 32 queryResponse.write("1"); 33 queryResponse.finish(); 34 }); 35 }