问了快10年的问题:浏览器敲个网址回车,发生了什么

感谢万能的stackoverflow
1. browser checks cache; if requested object is in cache and is fresh, skip to #9
浏览器检查缓存,如果请求的东西在缓存里面,跳第9步。
2. browser asks OS for server's IP address
浏览器向操作系统询问域名对应的IP地址。
3. OS makes a DNS lookup and replies the IP address to the browser
操作系统向DNS服务器,发起一个DNS查询。(此处向网关发送ARP包什么的BLAHBLAH)
4. browser opens a TCP connection to server (this step is much more complex with HTTPS)
浏览器向服务器建立一个TCP连接
5. browser sends the HTTP request through TCP connection
浏览器在TCP连接的基础上发送HTTP请求。
6. browser receives HTTP response and may close the TCP connection, or reuse it for another request
浏览器收到HTTP响应然后也许会关了TCP连接,或者再用它发起下一个请求(短连接和长连接)
7. browser checks if the response is a redirect or a conditional response (3xx result status codes), authorization request (401), error (4xx and 5xx), etc.; these are handled differently from normal responses (2xx)
浏览器检查是不是重定向或者条件响应(3xx),认证请求(401),错误(4xx或5xx),它们的响应方式不同于普通的2xx
if cacheable, response is stored in cache
如果能缓存,响应会被缓存
8. browser decodes response (e.g. if it's gzipped)
解码响应
9. browser determines what to do with response (e.g. is it a HTML page, is it an image, is it a sound clip?)
浏览器根据响应内容决定处理方式
10. browser renders response, or offers a download dialog for unrecognized types
渲染。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容