理解浏览器的重新加载与最大并发数
2019-04-16 08:25:19 阿炯

这里着重介绍浏览器的硬性重新加载和清空缓存并硬性重新加载

硬性重新加载 : 浅层次的清除历史记录,但不一定缓存完全清除。

清空缓存并硬性重新加载 : 可以深层次的清除所有的缓存(建议用这个)。

Chrome 系列


Windows和Linux操作系统下可行的操作

正常重新加载:Ctrl+R
硬性重新加载:Shift+F5 或 Ctrl+Shift+R 或 Ctrl+F5
清空缓存并硬性重新加载:按F12打开调试模式,右键工具栏的刷新按钮会出现这个选项(清空缓存并硬性重新加载)。

Ctrl + H:清除历史记录快捷键,快速调出清除历史记录界面。

Mozilla Firefox 系列

Ctrl+F5
Ctrl+Shift+R

Internet Explorer

Ctrl+F5
按Ctrl键的同时点击刷新按钮

以下是转自的外文对此类重载的说明(针对chrome):
Google Chrome supports three different reload functions:

Normal reload
Hard reload
Hard reload with cache clearing


Normal reload is the most straightforward function to explain. You activate it with a click on the reload button or with the keyboard shortcuts F5 or Ctrl-R.

Google Chrome uses the cache of the browser in this case but will validate the cached files during page load to make sure only resources that the server returns a 304 not modified response for are loaded from cache.

Hard reload is not exposed directly in the UI of the browser. You activate the function with the keyboard shortcut Ctrl-Shift-R, Shift-F5, or by holding down Shift before you activate the reload button.

Chrome ignores the cache and will load all resources from the web page again.

Google Chrome supports a third reload option and a somewhat hidden reload menu as well. You need to open the browser's Developer Tools with the keyboard shortcut F12 first as it is a prerequisite for it.

Right-click on the reload button afterward to display the reload menu. It includes the empty cache and hard reload option that you may use. What it does, is clear the browser cache before the hard reload is activated.

You may ask yourself what benefit the clearing of the cache has as hard reloads bypass the cache. The method takes situations into account where web pages may download additional content using JavaScript or other means that are not part of the initial page load process. These resources may be cached and as a consequence may be loaded from cache even if you do a hard reload.

Tip: Most web browsers support regular reloads and reloads that bypass the cache. The keyboard shortcuts mentioned above should work in most of them.



浏览器同域名请求的最大并发数限制

当我们在浏览网页的时候,对浏览速度有一个重要的影响因素,就是浏览器的并发数量。并发数量简单通俗的讲就是,当浏览器网页的时候同时工作的进行数量。如果同时只有2个并发连接数数量,那网页打开的时候只能依赖于这2条线程,前面如果有打开慢的内容,就会直接影响到后面的内容打开。但是如果同时有更多的并发连接数,这样就会大大的提高网页加载速度,浏览器的并发连接数也并非越大越好。下表概括了基于主机上运行的IE浏览器的版本的最大并发连接数、主机的连接速度和服务器的受支持的协议版本。

1,HTTP客户端一般对同一个服务器的并发连接个数都是有限制的。实际上,浏览器确实使用并行连接,但它们将并行连接的总数限制为少量(通常为四个)。服务器可以自由地关闭来自特定客户端的过多连接。

2,一些主流浏览器对HTTP 1.1和HTTP 1.0的最大并发连接数目,可以参考如下表格:

浏览器

HTTP / 1.1

HTTP / 1.0

IE 11

6

6

IE 10

6

6

IE 9

10

10

IE 8

6

6

IE 6,7

2

4

火狐

6

6

Safari 3,4

4

4

Chrome 4+

6

6

Opera 10.51+

8

   

iPhone 2

4

iPhone 3

6

iPhone 4

4

iphone 5

6

   

Android2-4

4


IE 浏览器的最大并发连接数

用"注册表编辑器"命令打开注册表编辑器,找到:
[HKEY_CURRRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings],可以看到MaxConnectionsPerServer和MaxConnectionsPer1_0Server,这两个键(分别是针对HTTP 1.1和HTTP 1.0的设置)。

对于IE 9

[HKEY_CURRRENT_USER\Software\Policies\Microsoft\Internet Exploer\Main\FeatureControl,可以看到FEATURE_MAXCONNECTIONSPER1_0SERVER和FEATURE_MAXCONNECTIONSPERSERVER

这两个键(分别是针对HTTP 1.1和HTTP 1.0的设置)


Firefox浏览器调整单个主机下的并发数

1.打开浏览器,在网址处输入:about:config

2.查找 network.http.max-persistent-connections-per-server 选项,默认是6,将其修改为N,来看改为1个并发的情况:

3.在访问页面,发现资源的加载被阻塞,同一时刻只能下载一个资源,绿色代表正在加载,红色代表正在阻塞。

4.在搜索项输入:network.http.max-connections

老版本值是30,新的版本是256。


从Yahoo关于网站优化的经典14条建议,在第2版中,已经更新到35条了,其中有需要减少请求连接数和减少DNS解析次数,由于在http协议中有对浏览器并发请求连接数的限制,1.1版本中规定了是2个,于是通常的优化网站加载速度的方法是采用多个域名增加浏览器对同一网页的请求并发连接数。