Netlify slow transfer on static file access

Hello !

It takes a long time to access static files from our application hosted on Netlify, around 7+ seconds to download a 1.2 Mb file.

Based on an other thread (Netlify answers slowly on static file access (after deploy?)), you should be able to investigate with the following x-nf-request-id: f87dca63-234e-4cf3-925b-b2197846a219-48672.

Request/Response DURATION
Request sent 0.10 ms
Waiting (TTFB) 321.24 ms
Content Download 7.39 s

Netlify site name : https://vibrant-mestorf-7285cd.netlify.app
Custom domain : https://staging-admin.thedeepsense.co

I have the same issue with application on 3 others environments, also deployed on Netlify.
I have no build problem with the application, which is working fine except for the download of this specified static file.

Thank you for your help !

Hey @Deepsense,
We looked into this and found a few things:

  • we’re showing that the Wasm file is a bit bigger, at about 4.5MB
  • we confirmed the slow response speeds you’re seeing from France- about 7s
  • when I request the file from the US west coast, I get the file in 3.8s
  • we show that the file has been requested 8 times over the last week

Putting this all together, we get a picture of a an asset that is large enough and infrequently requested enough to not be held in the cache of your nearest CDN node. Instead, requests for this file have to travel from you all the way to our origin in San Francisco. This explains why from the US, the load time is about what we’d expect: 1MB/s for an uncached asset.

We do have an issue internally where we’re discussing ways to improve response timing in situations like this.

In the meantime, depending on how you’re loading this file, you may be able to deploy it with a Netlify Function in eu-west-3 in Paris (other locations listed here) and have the function send it when needed, with hopefully better timing. That’s the best I can think of in this case, which may not have been what you wanted to hear, but should give you more of an understanding to move forward.

Let us know if this helps or you have any other questions!

Hello @jen

Thank you for your report and answers.

I will try what you said regarding Netlify Function in eu-west-3 in Paris.
I don’t know this Netlify feature, can you point me in the right direction in your documentation to configure it please ?

Regards.

Hey there,
Netlify Functions are AWS lambda functions under the hood. Here are our docs on them:

I thought that the ability to change function region would be included in your Pro plan, but it actually requires an upgrade to Functions Level 1:

Since serving the file in the way I described is an untested method, it’s definitely worth creating a demo and confirming that you can even load the file you need in this way. So, to start, I would deploy your site with a function in the default region. One of my colleagues suggested starting with something like this for the function code:

return {
  statusCode: 200,
  headers: {
    'Content-Type': 'application/wasm',
  },
  body: filecontents,
}

Your function file structure could be like this: https://github.com/kaganjd/examples/tree/master/func/send-down-pdf where you have a function directory that includes the function code and the static file you want to serve.

You would include the function endpoint in your static site, which should call the function that serves the specific file.

If you confirm that that works and makes business sense for you, you’d upgrade to Functions Level 1 and we’d move the function region closer to your users, which should make it load faster for them.

Whew, I know this is a lot and fairly involved, but I did want to share the details so you have a starting place and can make an informed decision. Please don’t hesitate to let us know if you have any questions as you try things out!