如何保持活动的HTTP可以在/在AJAX应用程序发挥作用 [英] How keep-alive of HTTP can/is play role in AJAX application

查看:136
本文介绍了如何保持活动的HTTP可以在/在AJAX应用程序发挥作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

保活它的存在,在HTTP。有人说,这很好,应使用,但我无法得到任何结论。 所以,请提供您的输入/答案/意见,所以我可以得到一些理由这一点,

  1. 在它能做什么?
  2. 方案,它应该和不应该做?
  3. 如何它可以使AJAX应用程序更好?
  4. 风险DO的和不要的如果有的话?

    感谢大家的投入。

解决方案

首先,如果您连接到服务器使用HTTP / 1.1,那么你很可能已经在使用保持活跃。

这是什么?逻辑上的HTTP是无连接协议。这是每个请求/响应服务器创建一个新的连接,做它的业务和断开连接。然而,在HTTP / 1.1的默认行为是保持连接打开的后续请求给服务器使用。该保持活跃头被添加到HTTP / 1.0,以允许这种行为来选择加入,在HTTP / 1.1服务器需要退出通过关闭连接本身和/或在发送连接闭头反应。

为什么是有益的?创建连接特别是那种需要进行身份验证可能需要一些时间。通过重新使用现有的连接的建立和验证的努力已大大减少。

它如何让你的AJAX应用程序更好?您可能已经从中受益。

有哪些风险?当制造通过共享设备的连接这可能使在代表客户端向服务器的连接是可能的其他客户端重新使用的连接,但是也可以使其它客户端使用该服务器具有一个连接鉴定以用于不同的用户。

"keep-alive" its there in HTTP. Some says it good should be used, but i am unable to get to any conclusion. So please provide your input/answer/views so i can get some ground for this,

  1. What it does?
  2. Scenario where it should and should not be done?
  3. How it can make AJAX application better ?
  4. Risks DO's and DONT's if any?

    Thank you all for inputs.

解决方案

First off if your connection to the server is using HTTP/1.1 then you are most likely already using "keep-alive".

What is it? Logically HTTP is a connectionless protocol. That is each request/response to the server creates a new connection, does its business and drops the connection. However in HTTP/1.1 the default behaviour is to keep the connection open for use by subsequent requests to the server. The "keep-alive" header was added to HTTP/1.0 to allow this behaviour to be opted into, in HTTP/1.1 the server needs to opt-out by closing the connection itself and/or sending a "connection-close" header in response.

Why is it beneficial? Creating a connection especially one that needs to be authenticated can take some time. By re-using an existing connection the setup and authentication effort is much reduced.

How can it make your AJAX app better? You are probably already benefitting from it.

What are the risks? When making a connection through a shared appliance which may make a connection to the server in the clients behalf it is possible for other clients to re-use the connection, however that also makes it possible for other clients to use a connection that the server has authenticated for a different user.

这篇关于如何保持活动的HTTP可以在/在AJAX应用程序发挥作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆