Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.



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


And squid config:

# http_port public_ip:port accel defaultsite= default hostname, if not provided
http_port 80 accel

# IP and port of your main application server (or multiple)
cache_peer 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
share|improve this question
up vote 0 down vote accepted

Solution described here:

Well, after trying all alternatives, I modified the source code to implement the feature.

I changed in the Squid-2.7-stable9 the file src/refresh.c:282:

282:    if (request) {


282:    if (request && FALSE) {

They do something like that in the 3.X to implement ignoreCc:

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

Worked as expected.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.