We’re running this code in a cloud worker. It is retrieving the page from our server, and goes on to make some small modifications to contentResponse.
var date1 = new Date(); console.log("fetching", url, " on ", date1); contentResponse = await fetch(request); var date2 = new Date(); console.log("got fetch - took", date2 - date1);
The problem is that around 20% of the requests end like this, taking over 60 seconds to respond despite being a Cache HIT
fetching / on Mon Mar 18 2019 04:00:15 GMT+0000 (Coordinated Universal Time) VM31 worker.js:133 got fetch - took 60035
Note that the data is returned successfully on this request; the page content loads fine, it just takes a long time.
Here’s a normal fetch that ran without the delay:
fetching / on Mon Mar 18 2019 03:59:18 GMT+0000 (Coordinated Universal Time) VM31 worker.js:133 got fetch - took 39
So interestingly the fetch seems to have a 60s delay - it looks like the fetch is a cache hit (I’ve confirmed this by checking my server logs, the fetch never hits the server) where it took 35ms for the fetch, but then didn’t complete the promise for an extra 60000ms.
Here’s a dump of the details from the cloudworker debugger - I’ve put the 1min request at the top, then the response headers and request headers
You can see there that it’s a CF-Cache-Status: Hit which somehow takes 60s. Very strange.
Appreciate any help or suggestions!