Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome sends two requests when downloading a PDF (and cancels one of them)

I noticed that whenever you download a PDF in Chrome, it consistently makes two requests, and then cancels one of them. This is causing the request to be registered twice in my Web app, which don't want. Is there a way to get Chrome to only make one request for PDFs?

I've researched this topic quite a bit now, and I have not found a sufficient answer. Closely-related answers suggest that the problem is that Chrome is looking for a favicon, but the network tab shows that it is actually making the same request twice, and then canceling the second request.

Is there a way to prevent Chrome from making the second request?

Below is a link to a random PDF file that I found through Google which when clicked should demonstrates the behavior. I would've posted a picture of my network tab in devtools but this is my first post on Stack Overflow, and the site is prohibiting me from uploading a picture.

https://www.adobe.com/enterprise/accessibility/pdfs/acro6_pg_ue.pdf

like image 578
gregmagdits Avatar asked Sep 22 '15 19:09

gregmagdits


People also ask

Why some PDF is not downloading in Chrome?

First, check if 'Download PDF files instead of automatically opening them in Chrome' is turned on in Chrome. When this is enabled, all PDF will be downloaded instead of view.

Why did Chrome cancel my download?

If your internet connection is unstable, slow or off while downloading files in Chrome, the Chrome downloading process may be stopped or stuck. If you have a limited bandwidth, the Google Chrome downloads may be also interrupted or stuck in the middle.

How do I stop Chrome from taking over my PDF files?

It's a quick fix if you follow these steps: Step 1: Open Chrome and type "about:plugins" into the omnibox at the top. Step 2: Scroll down and find Chrome PDF Viewer. Step 3: Click the "Disable" link to prevent PDFs from loading within Chrome.

Why does Chrome keep taking over my PDFs?

Sometimes even when setting Adobe Acrobat DC as the Default, downloaded PDFs will open in Chrome instead. This is because Chrome is set to use it's integrated PDF viewer when files are downloaded by default. You will need to turn this off to make it go away.


1 Answers

It looks like a bug in Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=587709

The problem is that Chrome, when it loads an iframe that returns a PDF stream, writes an "embed" tag inside that iframe which again contains the same URL as the iframe. This triggers a request for that URL again, but Chrome immediately cancels it. (see the network tab) But by that time, the damage is done.

We have the same issue here, and it does not occur in Firefox or IE.

We're still looking for a good solution to this problem.

like image 93
Moeri Avatar answered Oct 13 '22 01:10

Moeri