[squid-dev] [PATCH] Update refresh_pattern description regarding 'max' option

Garri Djavadyan garryd at comnet.uz
Thu Dec 1 05:47:10 UTC 2016


On Thu, 2016-12-01 at 00:56 +1300, Amos Jeffries wrote:
> On 21/11/2016 9:58 a.m., Garri Djavadyan wrote:
> > 
> > The patch adds description for undocumented behavior related to
> > 'max'
> > option of 'refresh_pattern' directive. I mean, 'max' option sets
> > value
> > for 'Cache-Control: max-age' header sent by Squid upstream. Feel
> > free to
> > modify the description. Thanks.
> > 
> 
> IIRC it is not supposed to affect just any request. Only;
>  a) the revalidation updates to HIT content need max-age, and that is
> to
> ensure newer data comes back.
>  b) sibling cache requests, because the content retrieved from a
> sibling
> cache is supposed to be cacheable (thus within max storable age).
> 
> That (b) situation is one we probably should remove. But it needs
> someone to analyse the use cases and figure out what should be going
> on
> now in the HTTP/1.1 era.
> 
> Amos

But it is not true actually. It is applied to any request if 'Cache-
Control: max-age' or 'Cache-Control: no-cache' were not set by a
client. Below is relevant code:

src/http.cc:

    /* append Cache-Control, add max-age if not there already */
    {
        HttpHdrCc *cc = hdr_in->getCc();

        if (!cc)
            cc = new HttpHdrCc();

#if 0 /* see bug 2330 */
        /* Set no-cache if determined needed but not found */
        if (request->flags.nocache)
            EBIT_SET(cc->mask, HttpHdrCcType::CC_NO_CACHE);
#endif

        /* Add max-age only without no-cache */
        if (!cc->hasMaxAge() && !cc->hasNoCache()) {
            // XXX: performance regression. c_str() reallocates
            SBuf tmp(request->effectiveRequestUri());
            cc->maxAge(getMaxAge(entry ? entry->url() : tmp.c_str()));
        }

        /* Enforce sibling relations */
        if (flags.only_if_cached)
            cc->onlyIfCached(true);

        hdr_out->putCc(cc);

        delete cc;
    }


Below is debug log for default squid.conf with 'debug_options ALL,1
11,2 22,9. Request if performed to Squid-5 with clean memory cache:

$ curl -v -s -x http://127.0.0.1:3128 http://mirror.comnet.uz/centos/7/
os/x86_64/GPL >/dev/null


2016/12/01 10:24:16.894 kid1| 11,2| client_side.cc(1333)
parseHttpRequest: HTTP Client local=127.0.0.1:3128
remote=127.0.0.1:46944 FD 11 flags=1
2016/12/01 10:24:16.894 kid1| 11,2| client_side.cc(1337)
parseHttpRequest: HTTP Client REQUEST:
---------
GET http://mirror.comnet.uz/centos/7/os/x86_64/GPL HTTP/1.1
Host: mirror.comnet.uz
User-Agent: curl/7.50.3
Accept: */*
Proxy-Connection: Keep-Alive
----------
2016/12/01 10:24:16.930 kid1| 22,3| refresh.cc(642) getMaxAge:
getMaxAge: 'http://mirror.comnet.uz/centos/7/os/x86_64/GPL'
2016/12/01 10:24:16.930 kid1| 11,2| http.cc(2280) sendRequest: HTTP
Server local=172.16.236.12:38256 remote=91.196.76.102:80 FD 13 flags=1
2016/12/01 10:24:16.930 kid1| 11,2| http.cc(2281) sendRequest: HTTP
Server REQUEST:
---------
GET /centos/7/os/x86_64/GPL HTTP/1.1
User-Agent: curl/7.50.3
Accept: */*
Host: mirror.comnet.uz
Via: 1.1 gentoo.comnet.uz (squid/5.0.0-BZR)
X-Forwarded-For: 127.0.0.1
Cache-Control: max-age=259200
Connection: keep-alive
----------


Garri


More information about the squid-dev mailing list