I've created a simple Node.js app which logs to console the current request.url
for every incoming HTTP request. When I refresh the page in Chrome on Mac OS X ML, I receive two requests for the same page. Why?
In comparison, when I use curl and request the same page, I receive only one request. Same one request if I refresh the page in Safari.
Why would Chrome send two requests for the same page?
Edit: I've looked into the request.headers
and found one difference: the accept
header.
Here is the header for the first request. Notice, it accepts a list of specific mimes.
{ host: 'www.pulsr.local:1337',
connection: 'keep-alive',
'cache-control': 'max-age=0',
accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17',
'accept-encoding': 'gzip,deflate,sdch',
'accept-language': 'en-US,en;q=0.8',
'accept-charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
cookie: 'PULSRSESSID=BBtDAWMVgbQZ8lXA6wv4Wg/vwwI=; PULSRSESSID=dsGxP494UxJueit2/u79AFiM5fw=' }
Here is the second request. This time it accepts everything.
{ host: 'www.pulsr.local:1337',
connection: 'keep-alive',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17',
accept: '*/*',
'accept-encoding': 'gzip,deflate,sdch',
'accept-language': 'en-US,en;q=0.8',
'accept-charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
cookie: 'PULSRSESSID=VGWRSG9zIokHjA2vLa1b+/fUqu8=; PULSRSESSID=dsGxP494UxJueit2/u79AFiM5fw=' }
Edit 2: I've checked and see that both requests are GET
requests.