[squid-users] If-Unmodified-Since implementation question

From: Guy Bashkansky <guybas_at_gmail.com>
Date: Thu, 10 Mar 2011 15:13:35 -0800

I'm trying to implement the If-Unmodified-Since (IUMS) capability in Squid 2.x.

When a client IUMS request comes, I raise a new request flag iums,
store the iums time, and send an IMS request to the origin. When the
origin response comes back, I modify the store entry memory object’s
reply status according to the IUMS time logic in both
httpProcessReplyHeader() and clientHandleIMSReply().

This works either when the IUMS precondition is satisfied (then I send
200 to client, instead of 304 typically) or for the cache *hit only*
when the IUMS precondition is unsatisfied (then I send 412 to client,
instead of 200 typically).

However, when the IUMS precondition is unsatisfied upon cache *miss*,
the origin's 200 response is still being sent to client, even after I
modify the store entry memory object’s reply status to 412 in
httpProcessReplyHeader(). I cannot figure out how and when the status
is being restored back to 200.

I’ve set gdb data-watch breakpoints over the store entry memory
object’s reply status. But then, later during the execution, gdb
reports watchpoint expression error: bad address.

I’m stuck now, and would really appreciate any help. Thanks.

On Tue, Jan 11, 2011 at 2:38 PM, Guy Bashkansky <guybas_at_gmail.com> wrote:
>
> I have to modify the behavior of a customized version of Squid 2.4
> STABLE6 code, either by configuration or by coding.  Currently I can
> not switch to any other Squid version, because of the customizations.
>
>
> Problem description:
>
> - When a client sends a byte-range request with an If-Unmodified-Since
> header AND the object in Squid's cache is stale, then this Squid
> version generates a request to origin with both IUMS and IMS headers,
> which is conflicting and undefined by RFC2616.  The origin throws an
> error.
>
>
> Proposed solution:
>
> - On an IMS check for a content that was requested with a UIMS header,
> Squid should only insert the IMS header, not the IUMS header.  (If
> only the IUMS header was added, then the origin would return origin
> content unnecessarily, since it hasn't changed from the the cached
> version.)
>
> - Once the origin check is complete, then Squid cache should compute
> IUMS calculations as defined in RFC2616, returning possibly a 206
> Partial or 412 precondition failed.
> http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
>
>
> Questions:
>
> - Is there any possibility to facilitate such behavior using Squid 2.4
> STABLE6 configuration?
>
> - If not, then where in the code should I start to look to make the
> necessary code change, and approximately how?
>
> - I could not find any notion of If-Unmodified-Since in the Squid 2.4
> STABLE6 code.  What's the best way to handle this?
Received on Thu Mar 10 2011 - 23:14:22 MST

This archive was generated by hypermail 2.2.0 : Fri Mar 11 2011 - 12:00:01 MST