6

I 301-redirect a link to track a click.

http://myurl.tld/redirect.php?target=http%3A%2F%2Ftarget.tld%2Ffile.pdf

I track the amount of calls and some other stats on redirect.php. It works well unless I redirect to a pdf file in Internet Explorer (I tested v11, might affect other versions).
In this case, redirect.php tracks dozens of clicks within a few seconds made by the same user.
Using fiddler I found out that the pdf is returned in chunks (HTTP status code 206 Partial Content) which means several requests are made instead of a single one.
Normally, you would expect the browser to make the subsequent calls to http://target.tld/file.pdf when target.tld delivers the pdf in chunks and this is exactly what most browsers do.
However, Internet Explorer decides to request http://myurl.tld/redirect.php?target=http%3A%2F%2Ftarget.tld%2Ffile.pdf again and again and again instead of requesting the target site.

Now my questions:
How can I tell IE not to call myurl.tld but instead target.tld?
Can I manipulate the headers in the 301-redirect, so that IE knows to request the file from target.tld?

Horen
  • 11,184
  • 11
  • 71
  • 113
  • 1
    Does setting the `Content-Location` header value help at all? – niemiro Jun 10 '15 at 10:20
  • 1
    Are you using `Cache-Control: no-cache`? I think IE honors that and may actively avoid caching the redirect. Even in situations where it makes sense, like ranged transfers of content. – m4ktub Jun 10 '15 at 15:30

1 Answers1

2

It looks like this might have been a bug fix/workaround to a (perceived) bug in IE 9 - which apparently was too agressive in remembering 301 redirects. https://answers.microsoft.com/en-us/ie/forum/ie9-windows_7/possible-bug-in-ie-with-http-code-301-permanent/33cd03f0-8c82-e011-9b4b-68b599b31bf5

Try using HTTP 308 instead of 301 for IE 11 and see if that helps your problem.

Kevin Keane
  • 1,506
  • 12
  • 24