当 max-age=0 时,Squid stale-while-revalidate 不起作用

当 max-age=0 时,Squid stale-while-revalidate 不起作用

Squid 2.7 始终到达后端,预期仅当缓存过期时才使用 stale-while-revalidate 到达后端,而不是在客户端触发 max-age=0 时。

脚本:

<?php

header('Cache-Control: public, max-age=10, stale-if-error=200, stale-while-revalidate=500');
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

sleep(2);
die("OK");

鱿鱼配置:

# 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 allow-miss originserver name=main

# 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
#header_access Last-Modified 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 . 10080 90% 999999 ignore-no-cache override-expire ignore-private

icp_port 0

答案1

解决方案描述如下:https://stackoverflow.com/questions/12846107/how-to-use-in-squid-2-7-the-3-1-feature-ignore-cc


好吧,在尝试了所有替代方法后,我修改了源代码来实现该功能。

我改变了Squid-2.7-stable9文件src/refresh.c282

282:    if (request) {

为了

282:    if (request && FALSE) {

他们在 3.X 中做了类似的事情来实现 ignoreCc:

269:    if (request && !request->flags.ignore_cc) {

按预期工作。

相关内容