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 defaultsite=mydomain.com

# 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

Solution described here: https://stackoverflow.com/questions/12846107/how-to-use-in-squid-2-7-the-3-1-feature-ignore-cc

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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