AutoProxy 缓存

AutoProxy 缓存

The WinHttpGetProxyForUrl function performs autoproxy lookup on a per-request basis for the specified URL. If multiple proxies are returned, client applications should test each proxy before sending the request (for more information, see theOnly One Proxy Server is Currently Supported section in AutoProxy Issues in WinHTTP). The information in this topic applies to calls toWinHttpGetProxyForUrl when the client specifies automatic proxy discovery.

WinHttpGetProxyForUrl函书对指定的URL访问时每次都要执行autoproxy发现功能。如果返回多个代理,客户程序还要在发送请求前测试每个代理(详情参见WinHTTP中的AutoProxy 问题Only One Proxy Server is Currently Supported 章节)。

WinHttpGetProxyForUrl optionally locates the autoproxy URL and downloads the autoproxy script from that site. WinHttp uses the autoproxy script to locate the proxy servers. Both the autoproxy URL and the autoproxy script are cached for the specified session. Only one autoproxy URL and script are cached for each session. Typically, the autoproxy script and URL are cached until the IP address associated with the computer changes. If a new IP address is detected during a call to WinHttpGetProxyForUrl, the call will attempt to locate a new autoproxy URL and script and cache the results. Only one user should be allowed per session, so that the cached data is not shared with other users on the computer. For more information, see WinHTTP Sessions Overview.

WinHttpGetProxyForUrl提供了定位autoproxy URL和从服务器下载autoproxy的功能选项。WinHttp使用autoproxy脚本定位代理服务器。autoproxy URL 和autoproxy脚本都会缓存在指定的会话中。在每个会话汇总只缓存一个autoproxy URL 和script。一般地,缓存的autoproxy script 和URL会在计算机IP发生变化时消失。如果调用WinHttpGetProxyForUrl时探测到新的IP地址,调用就会定位新的URL和脚本并缓存结果。一个会话只允许一个用户使用,因此缓存的数据不和计算机上其他用户共享。详情参见WinHTTP Sessions Overview

If the out-of-process service is active when WinHttpGetProxyForUrl is called, the cached autoproxy URL and script are available to the whole computer. However, if the out-of-process service is used, and thefAutoLogonIfChallenged flag in the pAutoProxyOptions structure is true, then the autoproxy URL and script are not cached. Therefore, callingWinHttpGetProxyForUrl with the fAutoLogonIfChallenged member set toTRUE results in additional overhead operations that may affect performance. The following steps can be used to improve performance.

当调用WinHttpGetProxyForUrl时,进程外服务被激活,缓存的autoproxy URL 和script对整个计算机来说就有效了。然而,如果进程外服务被使用,并且pAutoProxyOptions参数结构体中的AutoLogonIfChallenged标识被设为TRUE,那么autoproxy URL 和script就不会被共享。因此上述情况会影响性能表现。下列步骤可以被用来改善性能。

Aa383153.wedge(en-us,VS.85).gifTo improve performance

为改善性能

  1. Call WinHttpGetProxyForUrl with the fAutoLogonIfChallenged parameter set tofalse. The autoproxy URL and script are cached for future calls toWinHttpGetProxyForUrl.
  2. 调用WinHttpGetProxyForUrl时把fAutoLogonIfChallenged参数设为false。这样autoproxy URL 和script就会被缓存起来,供后续的WinHttpGetProxyForUrl使用。
  3. If Step 1 fails, with ERROR_WINHTTP_LOGIN_FAILURE, then callWinHttpGetProxyForUrl with the fAutoLogonIfChallenged member set toTRUE.
  4. 如果上一步失败,错误代码为ERROR_WINHTTP_LOGIN_FAILURE,然后调用WinHttpGetProxyForUrl,把参数fAutoLogonIfChallenged设为TRUE。

猜你喜欢

转载自blog.csdn.net/edger2heaven/article/details/45715903