dns

前端性能优化

别说谁变了你拦得住时间么 提交于 2019-12-25 03:53:57
  先让我们看看一张网页是怎么来的,也就是从用户输入完一个网址点下“ENTER”键到整个页面加载出来中间发生了什么。首先我们了解下HTTP过程: 一、寻找IP(每一步都是在上一步没找到的情况下进行的) 本地阶段: 1、浏览器搜索自身缓存; 2、搜索操作系统自身的DNS缓存; 3、地区本地HOST文件; 4、浏览器发送DNS系统调用; 路由阶段: 1、宽带运营商服务器查看本地缓存; 2、运营商服务器发起一个迭代DNS解析请求; com -> baidu.com -> www.baidu.com 3、运营商服务器把结果返回给操作系统内核同时缓存起来; 4、操作系统内核把结果返回个浏览器 浏览器得到IP了。 二、建立连接并获取内容 1、发起HTTP三次握手,建立TCP/IP连接; 2、发起HTTP请求; 3、服务器端读取数据库并处理数据后返回页面内容; 这样获得了一个页面,但是页面的js文件、css文件、图片都要经过这样的过程! 4、渲染页面; 我们写baidu.com和www.baidu.com同样都会跳转到百度首页,但是baidu.com是经过了一次301页面跳转到www.baidu.com的,多了一次DNS查询; 常见状态码: 1xx 请求已接受 2xx 处理完毕 3xx 重定向 4xx 客户端错误 5xx 服务器端错误 200 OK成功 400 客户端语法错误 401

关于性能优化的法则

≡放荡痞女 提交于 2019-12-25 03:52:44
规则1:减少HTTP请求 我们只有20%的时间花在所请求的HTML页面上,剩下的80%是发生在浏览器前端,特别是页面和页面中各种元素(图片、CSS、Javascript、 flash…)的下载之上。 图片技术,CSSsprite,内联图片和脚本,样式表的合并,这些技术既可以减少HTTP请求,又可以避免在性能和设计之间进行艰难的选择。 规则2:使用内容发布网络 内容发布网络(CDN)是一组分布在多个不同地理位置的web服务器,用于更加有效的向用户发布内容。 除了缩短时间之外,CDN还可以带来其他优势。他们的服务包括备份,扩展存储能力和进行缓存。CDN还有助于缓和web流量峰值压力,比如在获取天气或股市新闻,浏览流行的体育或娱乐事件时。 规则3:增加Expires header 现在的WEB页面都包含了大量的组件,并且其数量在不断增长,页面的初访者会进行很多的HTTP请求,但通过使用一个长久的Expires头,让这些组件被缓存,这会在后续的页面浏览中避免不必要的HTTP请求。长久的Expires头常用于图片,但应该用在所有的组件上,包括脚本,样式表。 规则4:压缩组件 如果http产生的响应包很小,传输时间就会很少,因为只需要很小的包从服务器传递到客户端。压缩响应包,并由此减少网络的响应时间,这是减少页面大小的最简单的技术,但影响是最大的。 规则5:将样式表放在顶部 规则6

在浏览器地址栏输入一个URL后回车,背后会进行哪些技术步骤?

六眼飞鱼酱① 提交于 2019-12-25 03:33:01
一个老问题了,希望在知乎上有更加详细深入的回答,谢谢。 正文 这个问题出现在面试场合的概率,可能比其它问题都要高。 为了让更多读者理解这个问题,接下来派出男主角小明出场,采用拟人的手法来阐述整个过程。 小明听说最近两天知乎有一个帖子挺火,问题的提出者是腾讯的总裁 Pony Ma,有一个回答是这样的: 于是小明想去看看精彩评论,于是开始了网上冲浪之旅。。。 小明打开浏览器,输入zhihu.com敲回车键。 在小明眼里,浏览器是自己的小奴才,让你干啥就干啥。 浏览器才不这么看,鄙人也是有自己独立的人格的,老板的命令如果是对的,那自然照做。那如果是错误的,那就不能听命不是? 如果小明输入的是 “zhi hu.com” 或 “zhi@hu.com1”, 这些网址都是非法无效的,浏览器就要拒绝小明的无理要求,提示小明出错了。 所以,第一步是浏览器对用户输入的网址做初步的格式化检查,只有通过以上检查才会进入下一步。 浏览器是用http还是https访问服务器呢? 小明并没有明确告知浏览器是用哪个协议,针对此种情况,浏览器有自己的预案,那就是默认使用http协议,除非小明输入的是“ https://zhihu.com ”。 所以,小明输入的网址被浏览器补齐为“ http://zhihu.com ” 。 浏览器知道,TCP/IP快递公司那帮王八蛋,只有告诉它们收件人的IP地址

How to configure windows server 2016 with DNS sub-domains to an IP address in the container

我的梦境 提交于 2019-12-25 03:28:20
问题 I have a windows server 2016 on Azure which I will use as host for windows containers. I want to publish the containers hosted on the Server using a subdomain. Azure gave me a sub-domain such as: myserver.australiaeast.cloudapp.azure.com. Once I've created my windows container I have the internal IP address for my container as 172.26.140.245. What I am trying to achieve is to create a subdomain called "container1" so that if we get any request to: container1.myserver.australiaeast.cloudapp

Subdomain for each user

匆匆过客 提交于 2019-12-25 03:28:10
问题 I own a website which gives every registered user a dedicated space like this: www.mywebpage.com/user1 www.mywebpage.com/user2 www.mywebpage.com/user3 Inside this path the user has his mini web site. I'd like to give my users not a path within my domain, but a second level domain like this: user1.mywebpage.com user2.mywebpage.com user3.mywebpage.com A lot of websites do this, but I can't figure out how to get it! Am I supposed to register a CNAME in my dns record for every single user? How

Determine site domain in BaseHTTPServer

↘锁芯ラ 提交于 2019-12-25 02:59:09
问题 I try to implement simple server on python based on HTTPServer. How can i extract information about site domain served in current request? I mean it can serv several domains such as site1.com and site2.com for example, how can i get it in this code: from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer class MyHandler(BaseHTTPRequestHandler): def do_GET(self): print "get" self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() #how can i get here host

Determine site domain in BaseHTTPServer

南笙酒味 提交于 2019-12-25 02:59:02
问题 I try to implement simple server on python based on HTTPServer. How can i extract information about site domain served in current request? I mean it can serv several domains such as site1.com and site2.com for example, how can i get it in this code: from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer class MyHandler(BaseHTTPRequestHandler): def do_GET(self): print "get" self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() #how can i get here host

How should dynamic Kubernetes/OpenShift DNS resolution be configured?

蓝咒 提交于 2019-12-25 01:49:39
问题 I'm unable to find relevant information on this, which is why I'm asking the question here. Instead of using /etc/hosts which is a hacky solution for resolving Kubernetes container names to their service IP addresses, what would the best method be to automatically or dynamically map new Kubernetes pods to their service IPs? I've heard using /etc/resolv.conf is one such method, but was unable to find exactly how that file should be configured for this scenario. 回答1: If you are using OpenShift

domain with www prefix not working on firebase hosting

孤人 提交于 2019-12-25 01:48:44
问题 i deployed vuejs app on firebase hosting with custom domain from godaddy connected to it with google provided A records. when i enter mywebsite.com it works . but when i enter www.mywebsite.com it doesn't redirect and shows error certificate . i want the www redirect to a non-www domain( example.com ) how to redirect ? how to solve this please any help? 回答1: You need to add a CNAME record for www as canonical name for it to work. 来源: https://stackoverflow.com/questions/53429442/domain-with

Creating Kubernetes service that reference external service by multiple ip addresses

柔情痞子 提交于 2019-12-25 01:46:13
问题 Is there a way in Kubernetes to create a service for an external service that should return multiple IP addresses? Currently I am hacking around this by creating an A record in my public DNS provider (route53) and then in Kubernetes creating a service: apiVersion: v1 kind: Service metadata: name: rabbitmq labels: app: rabbitmq spec: type: ExternalName externalName: rabbitmq.mydomainhere.dev Is there a way to create a service natively in Kubernetes that returns a fixed set of IP addresses that