File Download From Website Failing

We have a website for handling and processing RMA requests for our clients that we recently added to Cloudflare. This website has an option to export RMA data in the form of a .CSV file from the admin panel.

After switching our DNS to Cloudflare we are having a problem with this feature. It goes as follows:

  1. an Ajax GET request is made to generate the file and initiate the download
  2. after the file has been generated a response is received with the following header:
    HTTP/2.0 200 OK
    date: Thu, 09 May 2019 15:41:02 GMT
    content-type: application/ms-excel;charset=UTF-16LE
    content-length: 655036
    content-disposition: attachment; filename=[redacted].csv;
    expect-ct: max-age=604800, report-uri=“
    server: Cloudflare
    cf-ray: 4d44c64d7c5b8265-KBP
  3. the exported file is in the response and a file download is being initiated in the browser
  4. the download fails a split second after it has started (Chrome displays “Network Error”, Firefox displays “[filename] could not be saved, because the source file could not be read.”).

This problem does not occur if I set my hosts file to point to the server directly without going through Cloudflare.

I’ve tried to figure out why this is happening and how to fix it, but I haven’t been able to find any real solution. A similar issue seems to be described here: Downloads are failing - timing out , however, our downloads are containing the correct file size and are being interrupted way before the specified file size is reached.

Any ideas why this is happening?

Would you have any public URL where this could be reproduced? Do you have any page rules which might affect caching (though the headers you listed wouldnt suggest it is cached)?

Unfortunately none of this is public, which makes debugging quite a bit more difficult.

There are no page rules set for that domain. I’ve tired changing caching settings and enabling debugging mode to bypass the cache. Same results every time. The only workaround seems to be bypassing Cloudflare.

You mean development mode, right?

If you dont have a public URL it will be difficult for the community to debug, so I’d suggest to open a support ticket and include a connection ID of one of the failed downloads. For example the one from the request above 4d44c64d7c5b8265-KBP.

1 Like

If the intended behavior is downloading the file why not set Content-Type to:

Content-Type: application/octet-stream


I’m not in development mode right now, but I did try enabling it to see if it changes anything. I already have a ticket waiting for response. Thanks for the tip about adding the connection ID though.

I’m somewhat doubtful this will help as the download is initiated correctly, but gets interrupted, however, I’ll try it next week when I get back to the project.

I’ll post an update in the thread if I get any sort of success or if support gets back to me with something useful. For now, thanks for the tips.

I thought so until found some related issues on Google. Since your Content-Type is not common and many websites are already working behind CF and clients can download the content, changing that may be a quick fix. If that fixed the issue then something is wrong with CF.

This topic was automatically closed after 14 days. New replies are no longer allowed.