Re: [squid-users] Caching based on accept-language

From: Jeff Gerbracht <jeffgerbracht_at_gmail.com>
Date: Tue, 8 Feb 2011 12:25:46 -0500

More info, I bumped up logging to level 9, and it appears that both
requests are generating the same key though there is a Vary:
Accept-Language in the request header and the Accept-Language values
are different in the header. Assuming I'm reading the logs
correctly.

English request
2011/02/08 12:03:39.139| HttpMsg.cc(460) parseRequestFirstLine:
parsing possible request: GET
/gbbcApps/report?cmd=showReport&reportName=StateSummary&state=US-IL&year=2005
HTTP/1.1
Host: 127.0.0.1:3128
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,fr-ca;q=0.8,es-mx;q=0.6,en;q=0.4,es;q=0.2
---------------: ------------
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Referer: http://gbbc.birdsource.org/gbbcApps/report?cmd=showReport&reportName=StateSummary&state=US-IL&year=2005
Cookie: __utma=159824174.1016341557.1233610654.1263823722.1264607697.8;
__utma=60651899.1851875726.1263486292.1297177347.1297182297.6;
__utmc=60651899;
__utmz=60651899.1297177347.5.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);
__utmb=60651899.21.10.1297182297
Vary: Accept-Language
X-Forwarded-For: 132.236.164.124
X-Forwarded-Host: gbbc.birdsource.org
X-Forwarded-Server: gbbc.birdsource.org
Connection: Keep-Alive
.
.
.2011/02/08 12:03:39.141| storeGet: looking up 41D47F9900C0151C89F42C1B2CF93D9E
2011/02/08 12:03:39.141| clientProcessRequest2: default HIT
2011/02/08 12:03:39.141| StoreEntry::lock: key
'41D47F9900C0151C89F42C1B2CF93D9E' count=1
2011/02/08 12:03:39.141| UFSSwapDir::reference: referencing 0x1d577bf0 0/385
2011/02/08 12:03:39.141| store_client::copy:
41D47F9900C0151C89F42C1B2CF93D9E, from 0, for length 4096, cb 1,
cbdata 0x1d8dcd68
2011/02/08 12:03:39.141| cbdataLock: 0x1d8dcd68=1
2011/02/08 12:03:39.141| storeClientCopy2: 41D47F9900C0151C89F42C1B2CF93D9E
2011/02/08 12:03:39.141| cbdataLock: 0x1da54e88=1
2011/02/08 12:03:39.141| store_client::doCopy: co: 0, hi: 53985
2011/02/08 12:03:39.141| store_client::doCopy: Copying normal from memory

Request in French
2011/02/08 12:03:49.463| HttpMsg.cc(460) parseRequestFirstLine:
parsing possible request: GET
/gbbcApps/report?cmd=showReport&reportName=StateSummary&state=US-IL&year=2005
HTTP/1.1
Host: 127.0.0.1:3128
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: fr-ca,en-us;q=0.8,es-mx;q=0.6,en;q=0.4,es;q=0.2
---------------: ------------
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Referer: http://gbbc.birdsource.org/gbbcApps/report?cmd=showReport&reportName=StateSummary&state=US-IL&year=2005
Cookie: __utma=159824174.1016341557.1233610654.1263823722.1264607697.8;
__utma=60651899.1851875726.1263486292.1297177347.1297182297.6;
__utmc=60651899;
__utmz=60651899.1297177347.5.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);
__utmb=60651899.22.10.1297182297
Vary: Accept-Language
X-Forwarded-For: 132.236.164.124
X-Forwarded-Host: gbbc.birdsource.org
X-Forwarded-Server: gbbc.birdsource.org
Connection: Keep-Alive
.
.
.
2011/02/08 12:03:49.464| storeGet: looking up 41D47F9900C0151C89F42C1B2CF93D9E
2011/02/08 12:03:49.464| clientProcessRequest2: default HIT
2011/02/08 12:03:49.465| StoreEntry::lock: key
'41D47F9900C0151C89F42C1B2CF93D9E' count=1
2011/02/08 12:03:49.465| UFSSwapDir::reference: referencing 0x1d577bf0 0/385
2011/02/08 12:03:49.465| store_client::copy:
41D47F9900C0151C89F42C1B2CF93D9E, from 0, for length 4096, cb 1,
cbdata 0x1d8dcd68
2011/02/08 12:03:49.465| cbdataLock: 0x1d8dcd68=1
2011/02/08 12:03:49.465| storeClientCopy2: 41D47F9900C0151C89F42C1B2CF93D9E
2011/02/08 12:03:49.465| cbdataLock: 0x1da54e88=1
2011/02/08 12:03:49.465| store_client::doCopy: co: 0, hi: 53985
2011/02/08 12:03:49.465| store_client::doCopy: Copying normal from memory

On Tue, Feb 8, 2011 at 11:07 AM, Jeff Gerbracht <jeffgerbracht_at_gmail.com> wrote:
> Is cache keys using Vary headers available in Squid 3.1.   Is there
> something I need to enable?
>    Jeff
>
> On Tue, Feb 8, 2011 at 10:30 AM, Jeff Gerbracht <jeffgerbracht_at_gmail.com> wrote:
>> Hmmm, I have Vary  Accept Language added now to the response header
>> but I'm still getting a cache hit, even when I change browser
>> language.   Below is still returning a cache hit of the English
>> version of the page, which was previously cached by Squid.
>>
>> Response Headers
>> Date    Tue, 08 Feb 2011 15:26:23 GMT
>> Server  Apache-Coyote/1.1
>> Cache-Control   no-cache
>> Expires 0
>> Pragma  no-cache
>> Content-Type    text/html
>> Age     25
>> X-Cache HIT from crane.ornith.cornell.edu
>> Via     1.0 crane.ornith.cornell.edu (squid/3.1.10)
>> Warning 110 squid/3.1.10 "Response is stale"
>> Vary    Accept-Language
>> Connection      close
>> Transfer-Encoding       chunked
>>
>> Request Headers
>> Host    gbbc.birdsource.org
>> User-Agent      Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
>> rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)
>> Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
>> Accept-Language fr-ca,en-us;q=0.8,es-mx;q=0.6,en;q=0.4,es;q=0.2
>>
>> On Mon, Feb 7, 2011 at 11:42 PM, Amos Jeffries <squid3_at_treenet.co.nz> wrote:
>>> On 08/02/11 15:12, Jeff Gerbracht wrote:
>>>>
>>>> I'm trying to set up squid to cache several of our dynamic pages for
>>>> which we have both EN and FR translations.  We use the browser setting
>>>> for language to determine which language to return to the user so the
>>>> URL is the same for both languages.  Is there any way to enable Squid
>>>> 3.1 to use the URL in combination with the accept-language from the
>>>> header to generate the cache key.  Currently, whichever language is
>>>> first requested is what is returned by a cache hit.  We have apache in
>>>> front of squid so if squid can't do what we need, any suggestions on
>>>> how to work with apache and squid  in combination to cache both the
>>>> english and french versions of a page.
>>>
>>> Squid does not (yet) support that find-grained level of smart variant
>>> handling. It will happily cache variants on the full-text of the named
>>> headers though.
>>>
>>> What you need to do is specify the language variance in the same way you
>>> specify compressed/non-compressed variance.
>>>
>>> Sent from the web server:
>>>  Vary: Accept-Language
>>>
>>> (it may need combining with the existing Vary header values, probably to
>>> "Vary: Accept-Language, Accept-Encoding")
>>>
>>> With a ETag header as well wherever possible.
>>>
>>> Amos
>>> --
>>> Please be using
>>>  Current Stable Squid 2.7.STABLE9 or 3.1.10
>>>  Beta testers wanted for 3.2.0.4
>>>
>>
>>
>>
>> --
>> Jeff Gerbracht
>> Lead Application Developer
>> Neotropical Birds, Breeding Bird Atlas, eBird
>> Cornell Lab of Ornithology
>> 607-254-2117
>>
>
>
>
> --
> Jeff Gerbracht
> Lead Application Developer
> Neotropical Birds, Breeding Bird Atlas, eBird
> Cornell Lab of Ornithology
> 607-254-2117
>

-- 
Jeff Gerbracht
Lead Application Developer
Neotropical Birds, Breeding Bird Atlas, eBird
Cornell Lab of Ornithology
607-254-2117
Received on Tue Feb 08 2011 - 17:25:52 MST

This archive was generated by hypermail 2.2.0 : Wed Feb 09 2011 - 12:00:02 MST