Jump to content

Dowload Links Get Called 2x Via Android:Chrom


fivestringsurf
Go to solution Solved by kicken,

Recommended Posts

I have a php application that serves pdf downloads.  It works fine on all devices and browsers with one small but really annoying side-effect (edge-case for sure)

When I look at my download logs anytime the download is triggered from Chrome on Android it is called twice!  Bizarre behavior and I can't figure it out.

 

Some background:

 

The download is a pdf that get's created on the fly.

All requests get processed through my index.php controller.

 

I was serving the request with javascript via:

window.open('export?file=something_to_inform_the_controller');

Works great in all browsers and devices but android chrome triggers this twice.

 

So I got wise and though maybe a direct link would work better:

<a target="_blank" href="http://mysite.com/export?file=abc123" download="file.pdf">DL link</a>
or
<a target="_blank" href="http://mysite.com/export?file=abc123">DL link</a>
or
<a target="_self" href="http://mysite.com/export?file=abc123" download="file.pdf">DL link</a>
or
<a target="_self" href="http://mysite.com/export?file=abc123">DL link</a>

Nope, none of these flavors prevents android/chrome from double downloading.

 

Then I researched my php header settings and tried:

content-disposition: inline  vs.

content-disposition: attachment    with no success

 

Note, the download is logged when the controller processes the request for the download.  I have duplicated download events for all downloads on android/chrome.  It's strange that I have not found a solution online for this or maybe I'm overlooking something silly.

 

Any ideas?

Edited by fivestringsurf
Link to comment
Share on other sites

  • Solution

It's because the browser initially requests the URL. Once it determines that it's content it can't handle and needs to be downloaded it passes the URL off to a separate download manager application which will then re-request the url and complete the download in the background.

 

This behavior is by design, there isn't anything you can do to make it issue only a single request.

Edited by kicken
Link to comment
Share on other sites

@kicken,

 

excellent answer.  The reason I was most annoyed by this was when a user looks at their download history if they have been using an android device everything is doubled! 
I guest the solution is:

a) screw you android users (you're log activity is doubled for download requests)

b) don't log requests made by same user/link within <3 seconds of one another

 

Thanks again for your answer.

Edited by fivestringsurf
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.