如何验证用作反向代理的 Squid 是否正常工作? [英] How to verify that Squid used as a reversed proxy is working?

查看:80
本文介绍了如何验证用作反向代理的 Squid 是否正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望减少我们的其中一台 Web 服务器的负载,并且我们正在使用配置为反向代理的 squid 运行一些测试.

We want to decrease the load in one of our web servers and we are running some tests with squid configured as a reverse proxy.

配置如下:

http_port 80 accel defaultsite=original.server.com

http_port 80 accel defaultsite=original.server.com

cache_peer original.server.com parent 80 0 no-query originserver name=myAccel

cache_peer original.server.com parent 80 0 no-query originserver name=myAccel

acl our_sites dstdomain .contentpilot.net

acl our_sites dstdomain .contentpilot.net

http_access 允许 our_sites

http_access allow our_sites

cache_peer_access myAccel 允许 our_sites

cache_peer_access myAccel allow our_sites

cache_peer_access myAccel 全部拒绝

cache_peer_access myAccel deny all

我们遇到的情况是服务器几乎一直都在返回 TCP_MISS.

The situation we are having is that pretty much the server is returning TCP_MISS almost all the time.

1238022316.988     86 69.15.30.186 TCP_MISS/200 797 GET http://original.server.com/templates/site/images/topnav_givingback.gif - FIRST_UP_PARENT/myAccel -
1238022317.016     76 69.15.30.186 TCP_MISS/200 706 GET http://original.server.com/templates/site/images/topnav_diversity.gif - FIRST_UP_PARENT/myAccel -
1238022317.158     75 69.15.30.186 TCP_MISS/200 570 GET http://original.server.com/templates/site/images/topnav_careers.gif - FIRST_UP_PARENT/myAccel -
1238022317.344     75 69.15.30.186 TCP_MISS/200 2981 GET http://original.server.com/templates/site/js/home-search-personalization.js - FIRST_UP_PARENT/myAccel -
1238022317.414     85 69.15.30.186 TCP_MISS/200 400 GET http://original.server.com/templates/site/images/submenu_arrow.gif - FIRST_UP_PARENT/myAccel -
1238022317.807     75 69.15.30.186 TCP_MISS/200 2680 GET http://original.server.com/templates/site/js/homeMakeURL.js - FIRST_UP_PARENT/myAccel -
1238022318.666   1401 69.15.30.186 TCP_MISS/200 103167 GET http://original.server.com/portalresource/lookup/wosid/intelliun-2201-301/image2.jpg - FIRST_UP_PARENT/myAccel image/pjpeg
1238022319.057   1938 69.15.30.186 TCP_MISS/200 108021 GET http://original.server.com/portalresource/lookup/wosid/intelliun-2201-301/image1.jpg - FIRST_UP_PARENT/myAccel image/pjpeg
1238022319.367     83 69.15.30.186 TCP_MISS/200 870 GET http://original.server.com/templates/site/images/home_dots.gif - FIRST_UP_PARENT/myAccel -
1238022319.367     80 69.15.30.186 TCP_MISS/200 5052 GET http://original.server.com/templates/site/images/home_search.jpg - FIRST_UP_PARENT/myAccel -
1238022319.368     88 69.15.30.186 TCP_MISS/200 5144 GET http://original.server.com/templates/site/images/home_continue.jpg - FIRST_UP_PARENT/myAccel -
1238022319.368     76 69.15.30.186 TCP_MISS/200 412 GET http://original.server.com/templates/site/js/showFooterBar.js - FIRST_UP_PARENT/myAccel -
1238022319.377    100 69.15.30.186 TCP_MISS/200 399 GET http://original.server.com/templates/site/images/home_arrow.gif - FIRST_UP_PARENT/myAccel -

我们已经尝试删除所有缓存.有任何想法吗.会不会是我的网站每次都将某些内容标记为不同,即使自上次代理请求以来它没有改变?

We already tried removing all the cache memory. Any ideas. Could it be that my web site is marking some of the content different each time even though it has not change since the last time it was requested by the proxy?

推荐答案

原始服务器(Web 服务器)与您的内容一起发回哪些标头?为了可以被squid缓存,我相信你通常必须在响应头中指定Last-Modified或ETag.Web 服务器通常会自动为静态内容执行此操作,但是如果您的内容是动态提供的(即使来自静态源),那么您必须确保它们在那里,并处理请求标头,例如 If-Modified-Since 和 If-不匹配.

What headers is the origin server (web server) sending back with your content? In order to be cacheable by squid, I believe you generally have to specify either a Last-Modified or ETag in the response header. Web servers will typically do this automatically for static content, but if your content is being dynamically served (even if from a static source) then you have to ensure they are there, and handle request headers such as If-Modified-Since and If-None-Match.

此外,由于我在您随后提出的有关会话的问题中指出了这个问题---响应中是否出现了Vary"标头?例如,Vary: Cookie"告诉缓存内容可以根据请求中的 Cookie 标头而变化:因此静态内容希望将其删除.但是,如果存在会话,您的网络服务器可能会将其添加到所有请求中,而不管所提供数据的静态/动态性质如何.

Also, since I got pointed to this question by your subsequent question about sessions--- is there a "Vary" header coming out in the response? For example, "Vary: Cookie" tells caches that the content can vary according to the Cookie header in the request: so static content wants to have that removed. But your web server might be adding that to all requests if there is a session, regardless of the static/dynamic nature of the data being served.

根据我的经验,对 HTTP 标头进行一些实验以了解对缓存的影响非常有益:我记得发现解决方案并不总是显而易见的.

In my experience, some experimentation with the HTTP headers to see what the effects are on caching is of great benefit: I remember finding that the solutions were not always obvious.

这篇关于如何验证用作反向代理的 Squid 是否正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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