AJAX query weird delay between DNS lookup and initial connection on Chrome but not FF, what is it?

前端 未结 2 970
闹比i
闹比i 2021-02-14 10:25

I have an AJAX query on my client that passes two parameters to a server:

var url = window.location.origin + \"/instanceStats\"            
$.getJSON(url, { \'un         


        
相关标签:
2条回答
  • 2021-02-14 10:43

    I'm having it too, and it's exactly the same: my Node.js application serves Ajax requests and no matter which /url I request it's either 30ms or 300ms and it switches back and forth: odd requests are long, even requests are short.

    The thing I see in Chrome Web Inspector (aka Chrome DevTools) is that there is a long gap between "DNS lookup" and "Initial Connection".

    They say it's OCSP related here: http://www.webpagetest.org/forums/showthread.php?tid=12357

    OCSP is some kind of certificate validation protocol: https://en.wikipedia.org/wiki/Online_Certificate_Status_Protocol

    Moving from localhost to 127.0.0.1 seems to fix it: response times are 30ms now.

    0 讨论(0)
  • 2021-02-14 10:55

    I've run into this also. It only seems to happen when using localhost. If you use 127.0.0.1 (or even the computer name), it will not have the extra delay.

    0 讨论(0)
提交回复
热议问题