I have a simple service worker where I’m trying to receive uploaded data and calculate received chunk size in real time.
The problem is that - it looks like CF has some buffering before data comes to request handler or in other words - I think CF grabs the whole brody request before transfering it to service worker.
I checked timestamp at the beginning of the request on frontend side and I compared it with timestamp in service worker (at the beginning of request handler) and I can see delay ~5s for 20-25Mb data size. So, it looks like request handler comes into the game only when the whole file is uploaded to CF. Am I right?
There is an option to disable it in nginx, but is it possible to disable it in CF? Module ngx_http_proxy_module
Here is my service worker example.
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event))
})
async function fetchAndApply(event) {
var headers = new Headers();
headers.append('Cache-Control', 'no-cache');
headers.append('Access-Control-Allow-Origin', '*');
headers.append('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
var init = { "status": 200, "statusText": "ok", "headers": headers };
return new Response(Date.now(), init);
}