We have a page in php, that may take some time to load and the response time can be over 30 seconds, it has a heavy script and it is normal, not open to the public. This page saves a log on our database everytime it is executed, and I noticed that, when the page loads fast, the log is saved once, but if it takes longer to respond, the log is saved twice.
Weird enouph, this was only happening in Chrome, when opening the page on Firefox, even if it took long to load, the log was saved once. Which brought me to the deduction that Chrome was executing the page twice when the response time was long.
After inspecting the network in Chrome I found that in fact Chrome was loading the page twice:
First time it was canceled, then redirected (307) and finally loaded. (in his case it took more than a minute to load, but that is normal)
The redirection is not a 307 Temporary Redirect but a 307 Internal Redirect. After some more digging, it turns out that Chrome in fact has an extension that executes this redirections (see the anser by @Rob W. 307 Redirect when loading analytics.js in Chrome)
The question is:
- Why does Chrome make a 307 Internal Redirect (which do call the server twice)
- and how can I prevent it from the server side? (I don't want to have to modify the configuration from Chrome because I can't ask all the users to change their configuration)
Thanks!