struts2的优点和缺点
Every time you visit a web page, your browser fetches it by requesting all the assets of the page from a web server. Since the birth of the web, this has mostly been done via HTTP/1.1.
每次您访问网页时,浏览器都会通过从网络服务器请求页面的所有资产来获取它。 自网络诞生以来,这大部分是通过HTTP / 1.1完成的。
As time has passed, and technology has evolved, and websites have become ever more complex and asset-heavy, the HTTP/1.1 protocol has increasingly come under strain, with a lot of workarounds needed for dealing with performance issues.
随着时间的流逝,技术的发展以及网站变得越来越复杂和资产繁重 ,HTTP / 1.1协议变得越来越紧张,需要许多变通办法来解决性能问题 。
![developers at work](https://i-blog.csdnimg.cn/blog_migrate/f7732ec431310a1209e78faecd8ca87e.webp?x-image-process=image/format,png)
Web pages, as we know them today, are often stuffed with resources—such as images, text, fonts, etc.—which make them much heavier than those of the 1990s or even 2000s. Accordingly, it takes more time for them to load, so web designers and developers have come up with nifty workarounds to duck the issue. Still, it has become obvious that there's a need for an update to the HTTP protocol itself.
就像我们今天所知道的那样,网页通常充斥着资源,例如图像,文本,字体等,这使它们比1990年代甚至2000年代的资源重得多。 因此,加载它们需要花费更多时间,因此Web设计人员和开发人员提出了一些不错的解决方法来解决该问题。 不过,很明显,需要对HTTP协议本身进行更新。
HTTP/2 will bring some changes to the way pages are delivered to the browser. While ordinary Internet users might not see a big difference, designers and web developers will notice quite some. This article will look at what those changes are, and how they will affect you as a proficient tech user.
HTTP / 2将对页面传递到浏览器的方式进行一些更改。 虽然普通的Internet用户可能看不出太大的区别,但设计师和Web开发人员会注意到很多。 本文将研究这些变化是什么,以及它们将如何影响您作为熟练的技术用户。
HTTP / 1的工作方式 (How HTTP/1 Works)
To fetch the web page you'd like to visit, your browser communicates with the server. They interchange messages—the browser requesting the images, fonts and other resources needed with separate requests, and the server, in its turn, sending them as responses.
要获取您要访问的网页,您的浏览器将与服务器通信。 它们交换消息-浏览器请求单独请求所需要的图像,字体和其他资源,服务器依次将它们作为响应发送。
As a result, the flood of data through many connections causes congestion, and the page load speed slows down. To overcome the problem of too many requests being sent, and to make the best use of HTTP/1, inventive developers have used inlining, concatenation and image spriting. Fortunately for them, puzzling over the speed of performance will largely be a thing of the past when HTTP/2 comes.
结果,通过许多连接的数据泛滥会导致拥塞,并且页面加载速度会降低。 为了克服发送过多请求的问题,并充分利用HTTP / 1,本发明的开发人员使用了内联,串联和图像拼接。 对于他们来说幸运的是,当HTTP / 2出现时,对性能速度的困惑将在很大程度上已经成为过去。
![developers at work](https://i-blog.csdnimg.cn/blog_migrate/27fda3f2a1f847c01110b9ec8aaef572.webp?x-image-process=image/format,png)
HTTP / 2将如何工作 (How HTTP/2 Will Work)
Your browser will still send requests to a server and get responses with the assets needed for the web page to look as it should, but some nuances in between will change. HTTP/2 brings new features such as multiplexed streams, server push, header compression and binary format—each of which I'll examine in turn.
您的浏览器仍会向服务器发送请求,并获得网页看起来所需的资产响应,但两者之间的某些细微差别会改变。 HTTP / 2带来了新功能,例如多路复用流,服务器推送,报头压缩和二进制格式,我将依次检查其中的每一个。
复用流 (Multiplexed Streams)
Remember the congestions caused by many connections passing the resources such as text, fonts and pictures from the server to your browser? Multiplexing eliminates this problem by making those assets into smaller parts, passing them all via one connection, and then reassembling the resources after they've reached the final destination, the browser.
还记得许多连接将诸如文本,字体和图片之类的资源从服务器传递到浏览器所造成的拥塞吗? 多路复用通过将这些资产分成较小的部分,将它们全部通过一个连接传递,然后在它们到达最终目的地即浏览器之后重新组装资源,从而消除了此问题。
服务器推送 (Server Push)
Server push represents a more efficient way to deliver assets to a browser. In an HTTP/1 environment, the HTML page is sent to the browser, the browser has to parse it and decide what assets it might need, then request those assets from the server.
服务器推送是将资产交付到浏览器的一种更有效的方式。 在HTTP / 1环境中,HTML页面被发送到浏览器,浏览器必须对其进行解析并确定可能需要的资产,然后从服务器请求这些资产。
HTTP/2 is more proactive in this regard, sending assets that the browser is likely to need without it having to ask. These assets go to the browser's cache, and are available immediately if and when they're needed, which is a plus for performance.
HTTP / 2在这方面更为主动,无需浏览器即可发送浏览器可能需要的资产。 这些资产将进入浏览器的缓存,并在需要和需要时立即可用,这对于性能而言是一个加分项。
头压缩 (Header Compression)
In HTTP/1, every request sent has a small piece of additional data attached—HTTP headers—that describe how a browser or a server behaves. On average, browsers are able to make about six connections at once, but given that the number of connections needed to load a typical web page can be up around 100, this leaves a lot of data to be retrieved, which takes time and bandwidth.
在HTTP / 1中,发送的每个请求都有一小部分附加数据-HTTP标头-描述浏览器或服务器的行为。 平均而言,浏览器能够一次建立约6个连接,但是考虑到加载典型网页所需的连接数最多可以达到100个 ,因此需要检索大量数据,这需要时间和带宽。
When an HTTP/2 connection is established, all the headers are packed into one compressed block to be sent as a unity. It gets across faster, and when the transmission is finished, the header block is decoded.
建立HTTP / 2连接后,所有标头都打包到一个压缩块中,作为一个整体发送。 它的传输速度更快,并且在传输完成后,将对头块进行解码。
二进制而不是文本格式 (Binary Instead of Textual Format)
The textual format has some extra overhead and needs to be refined, while the binary one does not need any parsing. It's also a lot more compact. Additional work of a server means additional time to wait for the web page to be loaded. That is why the binary format, with its being easier to process, is a justified enhancement.
文本格式有一些额外的开销,需要改进,而二进制格式不需要任何解析。 它也更紧凑。 服务器的额外工作意味着等待网页加载的额外时间。 这就是为什么二进制格式易于处理,是有道理的增强功能的原因。
![developers at work](https://i-blog.csdnimg.cn/blog_migrate/1d75805dff778b959bf40828c90429d1.webp?x-image-process=image/format,png)
开发人员现在可以做些什么 (What Developers Will Be Able to Do Differently Now)
Developers will no longer have to sprite images, do inlining and concatenate files, because there will be no need to reduce the number of requests on a web page. Basically, this is going to be the biggest change in their routine. However, there is more to be said about the internal changes that might somehow affect their work.
由于不再需要减少网页上的请求数量,因此开发人员将不再需要精简图像,进行内联和连接文件。 基本上,这将是他们日常工作中最大的变化。 但是,关于可能会影响其工作的内部更改还有很多要说的。
注意事项 (Things to Be Aware Of)
Though it's not required by the actual HTTP/2 specification, most browsers supporting HTTP/2 will require HTTPS encryption. This means that, if your HTTP/2 site is not served over an encrypted connection, visitors will either have to find some other client to visit your site or miss out.
尽管实际的HTTP / 2规范并不需要,但是大多数支持HTTP / 2的浏览器都需要HTTPS加密。 这意味着,如果未通过加密连接为您的HTTP / 2站点提供服务,则访问者将不得不找到其他客户端来访问您的站点,或者错过访问。
Although there's something of a push these days for sites to be served via HTTPS, this requirement by browsers has drawn criticism, and will no doubt represent a stumbling block for some considering the switch to HTTP/2. (For more tips on What HTTPS is, and how to implement it, read SitePoint's recent introduction to HTTPS.)
尽管最近通过HTTPS服务的网站有所发展 ,但浏览器的这一要求引起了批评,对于某些考虑切换到HTTP / 2的人来说,无疑是一个绊脚石。 (有关HTTPS是什么以及如何实现的更多提示,请阅读SitePoint最近对HTTPS的介绍 。)
The web will transition painlessly for the public. The modifications and upgrades needed for the new version of the protocol to work will take place in servers and browsers. Servers will be updated over time to eventually support both protocols. Browsers supporting the new protocol will switch to HTTP/2 automatically. At the same time, the older ones will not understand it. As a developer, you'll need to know whether both your browser and the server you are using support HTTP/2 to ensure the connection will be upgraded to it.
网络将为公众轻松过渡。 新版本协议生效所需的修改和升级将在服务器和浏览器中进行。 服务器将随着时间的推移进行更新,以最终支持这两种协议。 支持新协议的浏览器将自动切换到HTTP / 2。 同时,年长的人不会理解它。 作为开发人员,您需要知道您的浏览器和所使用的服务器是否都支持HTTP / 2,以确保将连接升级到该版本。
一些争议 (Some Controversy)
While many are enthusiastic about HTTP/2, others, such as Poul-Henning Kamp, are not so impressed. Kamp sees HTTP/2 as “really just a grandiose name for HTTP/1.2”, and suggests that it will most likely not last long, if it takes off at all.
虽然许多人热衷于HTTP / 2,其他诸如波尔·亨宁·卡普,没有那么 深刻的印象 。 坎普(Kamp)认为HTTP / 2“实际上只是HTTP / 1.2的一个宏伟名称”,并建议说,即使它全部起飞,它也很可能不会持续很长时间。
According to him, the new protocol does not solve actual problems, but rather concentrates too much on bandwidth. A better focus, he suggests, would be to kill cookies as a concept and replace them with a session/identity facility. That would go some way to improving privacy in a world of heightened security concerns. As it is, HTTP/2, Kamp argues, does nothing to significantly improve privacy.
据他介绍,新协议并不能解决实际问题,而是过于关注带宽。 他建议,更好的重点是将cookie作为一种概念杀死,并用会话/身份工具代替它们。 在安全问题日益严重的情况下,这将有助于改善隐私。 Kamp认为,HTTP / 2本身并不能有效改善隐私。
看到不同 (See the Difference)
This Akamai demo illustrates how resources are loaded concurrently in the two versions of the protocol. The first picture is loaded via HTTP/1 and six concurrent connections (if you are using Google Chrome), while the second one comes as a whole via HTTP/2 and all parts loaded simultaneously.
这个Akamai演示说明了如何在协议的两个版本中同时加载资源。 第一张图片是通过HTTP / 1和六个并发连接(如果您使用的是Google Chrome)加载的,而第二张图片是通过HTTP / 2作为一个整体加载的,所有部分同时加载。
![akamai demo screenshot](https://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2015/10/1445574376akamai.jpg)
If you'd like to have a more profound look at how differently data is loaded through the connections in the protocols, check out this golang.org example. It lets you try different latency settings, so that you can see how data would be loaded concurrently on devices of different capacity. The longer the delay, the more visible it is that HTTP/2 wins in terms of performance.
如果您想更深入地了解通过协议中的连接加载数据的方式, 请查看以下golang.org示例 。 它使您可以尝试不同的延迟设置,以便可以看到如何在不同容量的设备上同时加载数据。 延迟时间越长,就性能而言HTTP / 2获胜就越明显。
![Golang gophertiles screenshot](https://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2015/10/1445574007gophertiles.jpg)
底线 (Bottom Line)
HTTP/2 is going to come softly for ordinary users, and with a few choices to be made by those working with the web.
对于普通用户而言,HTTP / 2将变得轻柔,并且使用Web的用户可以选择几种方式。
In general, sites will be more secure and will load faster. The protocol does not bring any cardinal changes, possibly because such changes are more difficult to implement—both technically and politically. This is why HTTP/2 will possibly not serve us that long.
通常,站点将更安全并且加载速度更快。 该协议没有带来任何根本性的改变,可能是因为这种改变在技术上和政治上都更难以实施。 这就是为什么HTTP / 2可能不会为我们服务那么长时间的原因。
The world of technology is evolving more rapidly each year, so we might need something else in a few years. My personal hope is that the next protocol will be more flexible, and braver in meeting the challenges of changing technologies.
技术世界每年都在发展,因此几年后我们可能还需要其他东西。 我个人的希望是,下一个协议将更加灵活,并且能够更灵活地应对不断变化的技术挑战。
翻译自: https://www.sitepoint.com/http2-the-pros-the-cons-and-what-you-need-to-know/
struts2的优点和缺点