Table of Contents
当源站出现问题时如何使用户的请求暂时可以得到响应
Home php教程 php手册 当源站出现问题时如何使用户的请求暂时可以得到响应

当源站出现问题时如何使用户的请求暂时可以得到响应

Jun 13, 2016 am 08:41 AM
android

当源站出现问题时如何使用户的请求暂时可以得到响应

源站出现问题,不能给用户返回请求的内容的时候,有什么办法使用户仍然取到内容,虽然是过期的内容?
方法1:通过增加ats插件实现:
为了防止源站出现问题,如出现超时的情况,导致数据没有正常返回,返回错误码如502、504的时候,ats代理服务器会直接返回给用户502、504,影响用于体验,ats可通过增加插件功能实现当ats接收到源站返回的502、504时如果ats本地存在过期的缓存数据,则把过期的缓存数据暂时返回给用户,在用户看来是200的成功访问。

方法2:通过ats自带的处理机制:
如果源站不能给ats返回数据,如源站服务停掉了,机器宕掉了,则此时如果ats中有缓存则会返回TCP_REFRESH_FAIL_HIT/200 ,之后再次访问一直为TCP_HIT/200 ,直到proxy.config.http.cache.max_stale_age这个缓存值到了,以后再次请求返回TCP_REFRESH_FAIL_HIT/502

records.config中的配置项:
proxy.config.http.cache.max_stale_age INT 604800
上面配置项的含义:在不能缓存该对象之前,旧对象能够响应的最大时间(默认一周604800s)。

上述两种方法达到预期效果的前提是:ats中有缓存且过期了
==========
在上面方法2的情况下测试:
下面为客户端的部分响应头信息的区别:
1. 服务器正常提供服务,正常响应(TCP_HIT/200):
Proxy-Connection: keep-alive
* Connection #0 to host 192.168.10.74 left intact
* Closing connection #0

2. 服务器stop下再次发送相同请求(TCP_REFRESH_FAIL_HIT/200):
* HTTP/1.1 proxy connection set close!
* Closing connection #0

3.上面2的基础上再次发送多条相同请求(TCP_HIT/200):
Proxy-Connection: keep-alive
* Connection #0 to host 192.168.10.74 left intact
* Closing connection #0

4.服务器stop下当配置值604800s到了后,再次发送请求(TCP_REFRESH_FAIL_HIT/502):
Proxy-Connection: Keep-Alive
>
* Connection #0 to host 192.168.10.74 left intact
* Closing connection #0

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades Sep 12, 2024 pm 12:23 PM

New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades

Samsung Galaxy S25 Ultra leaks in first render images with rumoured design changes revealed Samsung Galaxy S25 Ultra leaks in first render images with rumoured design changes revealed Sep 11, 2024 am 06:37 AM

Samsung Galaxy S25 Ultra leaks in first render images with rumoured design changes revealed

IFA 2024 | TCL\'s NXTPAPER 14 won\'t match the Galaxy Tab S10 Ultra in performance, but it nearly matches it in size IFA 2024 | TCL\'s NXTPAPER 14 won\'t match the Galaxy Tab S10 Ultra in performance, but it nearly matches it in size Sep 07, 2024 am 06:35 AM

IFA 2024 | TCL\'s NXTPAPER 14 won\'t match the Galaxy Tab S10 Ultra in performance, but it nearly matches it in size

Vivo Y300 Pro packs 6,500 mAh battery in a slim 7.69 mm body Vivo Y300 Pro packs 6,500 mAh battery in a slim 7.69 mm body Sep 07, 2024 am 06:39 AM

Vivo Y300 Pro packs 6,500 mAh battery in a slim 7.69 mm body

New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades Sep 12, 2024 pm 12:22 PM

New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades

Samsung Galaxy S24 FE billed to launch for less than expected in four colours and two memory options Samsung Galaxy S24 FE billed to launch for less than expected in four colours and two memory options Sep 12, 2024 pm 09:21 PM

Samsung Galaxy S24 FE billed to launch for less than expected in four colours and two memory options

Motorola Razr 50s shows itself as possible new budget foldable in early leak Motorola Razr 50s shows itself as possible new budget foldable in early leak Sep 07, 2024 am 09:35 AM

Motorola Razr 50s shows itself as possible new budget foldable in early leak

Xiaomi Redmi Note 14 Pro Plus arrives as first Qualcomm Snapdragon 7s Gen 3 smartphone with Light Hunter 800 camera Xiaomi Redmi Note 14 Pro Plus arrives as first Qualcomm Snapdragon 7s Gen 3 smartphone with Light Hunter 800 camera Sep 27, 2024 am 06:23 AM

Xiaomi Redmi Note 14 Pro Plus arrives as first Qualcomm Snapdragon 7s Gen 3 smartphone with Light Hunter 800 camera

See all articles