Hello!

Currently it is possible for squid to send out Cache-Control: max-age=XXX, 
no-cache
combination. But max-age does not make any sense when there is a no-cache flag.

Here is a patch to fix it. The patch skips setting max-age if there is no-cache 
flag.
If the client has sent the combination, it is forwarded to the server as before.

Index: http.c
===================================================================
RCS file: /squid/squid/src/http.c,v
retrieving revision 1.441
diff -u -p -r1.441 http.c
--- http.c      25 Apr 2008 20:39:36 -0000      1.441
+++ http.c      27 Apr 2008 04:59:06 -0000
@@ -1332,15 +1334,15 @@ httpBuildRequestHeader(request_t * reque
        HttpHdrCc *cc = httpHeaderGetCc(hdr_in);
        if (!cc)
            cc = httpHdrCcCreate();
-       if (!EBIT_TEST(cc->mask, CC_MAX_AGE)) {
+       /* Set no-cache if determined needed but not found */
+       if (orig_request->flags.nocache && !httpHeaderHas(hdr_in, HDR_PRAGMA))
+           EBIT_SET(cc->mask, CC_NO_CACHE);
+       if (!EBIT_TEST(cc->mask, CC_NO_CACHE) && !EBIT_TEST(cc->mask, 
CC_MAX_AGE)) {
            const char *url = entry ? storeUrl(entry) : 
urlCanonical(orig_request);
            httpHdrCcSetMaxAge(cc, getMaxAge(url));
            if (strLen(request->urlpath))
                assert(strstr(url, strBuf(request->urlpath)));
        }
-       /* Set no-cache if determined needed but not found */
-       if (orig_request->flags.nocache && !httpHeaderHas(hdr_in, HDR_PRAGMA))
-           EBIT_SET(cc->mask, CC_NO_CACHE);
        /* Enforce sibling relations */
        if (flags.only_if_cached)
            EBIT_SET(cc->mask, CC_ONLY_IF_CACHED);

Reply via email to