Squid stale-while-revalidate not working when max-age=0

Posted by Wiliam on Server Fault See other posts from Server Fault or by Wiliam
Published on 2012-10-11T18:57:23Z Indexed on 2012/10/18 23:04 UTC
Read the original article Hit count: 232

Filed under:
|

Squid 2.7 always reaches backend, expected is to reach backend using stale-while-revalidate only when cache expires, not when client triggers max-age=0.

Script:

<?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");

And squid config:

# 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

© Server Fault or respective owner

Related posts about squid

Related posts about reverse-proxy