我想在同一臺機器的php應用程序前面使用squid作爲反向緩存代理,並且永遠不會讓用戶到達後端,始終加載過時的緩存在背景中。魷魚2.7和客戶端頁眉max-age = 0
我使用在端口80編譯魷魚2.7 Stable9與Centos的6.3(x86_64的)的自和Apache + PHP是在同一臺機器與所述端口8000
的阿帕奇+ PHP的響應頭將其發送到魷魚:
header('Cache-Control: max-age=10, stale-while-revalidate=15, stale-if-error=20');
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
當我問一個頁面魷魚,第一次重新驗證並在下一次使用總是陳舊的,但這個工程與Firefox WebDevelopersTools延伸DISABLE CACHE緩存選項。
不同的是,當高速緩存未禁用,客戶端發送緩存控制:最大年齡= 0和的If-Modified-由於和魷魚總是和重新驗證連接到後端。
在魷魚3.2它如預期使用ignore-cc但在2.7中沒有這樣的選項。
這裏是我的squid.conf:
# http_port public_ip:port accel defaultsite= default hostname, if not provided
http_port 80 accel defaultsite=mydomain.com
# IP and port of your main application server (or multiple)
cache_peer 127.0.0.1 parent 8000 0 no-query originserver name=main
cache_peer_domain main mydomain.com
# Do not tell the world that which squid version we're running
httpd_suppress_version_string on
# Remove the Caching Control header for upstream servers
header_access Cache-Control deny all
# log all incoming traffic in Apache format
logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh
access_log /usr/local/squid/var/logs/squid.log combined all
cache_effective_user squid
refresh_pattern nocache=true 0 0% 0
icp_port 0
我想在PHP應用程序選擇緩存時間,從來沒有讓用戶看到重新驗證的等待時間,這就是爲什麼我使用的是2.7版本與陳舊,同時,重新驗證。與緩存請求
實例啓用:
GET /some-page HTTP/1.1
Host: mydomain.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1 FirePHP/0.7.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: es-es,es;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
x-insight: activate
If-Modified-Since: Thu, 11 Oct 2012 10:14:52 GMT
Cache-Control: max-age=0
HTTP/1.0 200 OK
Date: Thu, 11 Oct 2012 10:29:31 GMT
Server: Apache/2.2.22 (PowerStack)
Last-Modified: Thu, 11 Oct 2012 10:29:32 GMT
Content-Type: text/html; charset=UTF-8
X-Cache: MISS from localhost
X-Cache-Lookup: HIT from localhost:80
Via: 1.1 localhost:80 (squid)
Connection: close
例如使用禁用緩存(我希望發生的事情):此處描述
GET /some-page HTTP/1.1
Host: mydomain.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1 FirePHP/0.7.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: es-es,es;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
x-insight: activate
HTTP/1.0 200 OK
Date: Thu, 11 Oct 2012 10:36:53 GMT
Server: Apache/2.2.22 (PowerStack)
Last-Modified: Thu, 11 Oct 2012 10:36:53 GMT
Content-Type: text/html; charset=UTF-8
Age: 2
Content-Length: 16725
X-Cache: HIT from localhost
X-Cache-Lookup: HIT from localhost:80
Via: 1.1 localhost:80 (squid)
Connection: keep-alive