[squid-users] My cache gived me a content-length of 0, and a 200 TCP_REFRESH_UNMODIFIED_ABORTED

Amos Jeffries squid3 at treenet.co.nz
Wed Feb 24 14:43:43 UTC 2021


On 25/02/21 12:50 am, Señor J Onion wrote:
> I am new to Squid, I have been trying to get this to work for almost two weeks now, and have found nothing in the archives.
> 
> This is my curl command (you will get a 403 forbidden by the time you run this dear reader):
> 
> curl -s -D - -o /dev/null -G -d "alt=media" -x "http://localhost:3128" http://storage.googleapis.com/omgimg.appspot.com/test.jpeg -H "host:storage.googleapis.com" -H "x-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" -H "x-amz-date:20210224T111631Z" -H "authorization:AWS4-HMAC-SHA256 Credential=GOOG1EGG4VCQ2EVRCJ2JCIO7ZDSZ3CY45Q72ATYZU2P32HITBFUOVQ6TEBWXI/20210224/auto/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=77a60480e47dda2b65ef3ebcd72a032458685e74e2560bb9083dbb03c3f6c13d”
> 
> 
> These are the HTTP response headers:
> 

Actually these are *half* the response headers. There are also the 
response headers received y Squid from the server.

The key details to explain your problem are in those other 
request-response headers going between Squid and server.


> 
> FIRST RUN:
> 
> HTTP/1.1 200 OK
> X-GUploader-UploadID: ABg5-UwzmWjdWRPkonOxhLl3rUUik6wN3MB_ME1w1pxS5Rtmp_Cl1AAiP5G3tA9oXpFfAMnLCn5Pb8VW1mioc6GI-wJDun1S_g
> Expires: Wed, 24 Feb 2021 11:20:08 GMT
> Date: Wed, 24 Feb 2021 11:20:08 GMT
> Cache-Control: private, max-age=0
> Last-Modified: Tue, 04 Aug 2020 12:09:00 GMT

First clue:
   This object is not allowed to be cached. If a modern Squid is forced 
to cache anyway, the server will be checked for updates before it is 
delivered anywhere.


> ETag: "d5b65c332fb6f80a0eade692b40b4afd"
> Content-Type: image/jpeg
> x-goog-hash: crc32c=6ijxaQ==
> x-goog-hash: md5=1bZcMy+2+AoOreaStAtK/Q==
> x-goog-storage-class: STANDARD
> Accept-Ranges: bytes
> Content-Length: 2296040
> Server: UploadServer
> X-Cache: MISS from 80396e157a13
> X-Cache-Lookup: MISS from 80396e157a13:3128
> Via: 1.1 80396e157a13 (squid/3.5.27)
> Connection: keep-alive
> 
> Squid log: 200 2296721 TCP_MISS:HIER_DIRECT
> 
> 
> SECOND RUN:
> 
> HTTP/1.1 200 OK
> Content-Type: image/jpeg
> x-goog-hash: crc32c=6ijxaQ==
> x-goog-hash: md5=1bZcMy+2+AoOreaStAtK/Q==
> x-goog-storage-class: STANDARD
> Accept-Ranges: bytes
> X-GUploader-UploadID: ABg5-UzooDZGnVTXxGIWQ2i25EasnR3glFz41FfUFvclACmZb3iDccpSXsGbRH0cr-8lofOc6Wb3knUzYMTgj_wdrzo
> Expires: Wed, 24 Feb 2021 11:20:17 GMT
> Date: Wed, 24 Feb 2021 11:20:17 GMT
> Cache-Control: private, max-age=0
> Last-Modified: Tue, 04 Aug 2020 12:09:00 GMT
> ETag: "d5b65c332fb6f80a0eade692b40b4afd"
> Content-Length: 0
> Server: UploadServer
> Age: 0
> X-Cache: HIT from 80396e157a13
> X-Cache-Lookup: HIT from 80396e157a13:3128
> Via: 1.1 80396e157a13 (squid/3.5.27)
> Connection: keep-alive
> 
> Squid log: 200 651397 TCP_REFRESH_UNMODIFIED_ABORTED:HIER_DIRECT
> 

Second clue is the REFRESH and UNMODIFIED tags. Squid revalidated with 
the server. The server said no changes happened beyond some headers.

Third clue(s) are the differences in headers between first and second 
responses to the client.

X-Cache, Via, Age, and Connection are generated by Squid. So ignore those.

The remainder of headers are from the server. The second reply is the 
HIT object with header changes provided in the servers 304 message.
  Expires, Date, X-GUploader-UploadID, and Content-Length changed.


> 
> I don’t know why the second time round, I a) don’t get a HIT, and b) why my content-length is 0.
> 


Because the server told Squid the objects length has become 0 bytes.

<https://bugs.squid-cache.org/show_bug.cgi?id=4882#c11> has some more 
details.

The very latest HTTP specification text has made it even clearer:

"
    For messages that do not include content, the
    Content-Length indicates the size of the selected representation
"

"
   Any response ... 304 (Not Modified) status
   code is always terminated by the first empty line after the
   header fields, regardless of the header fields present in the
   message, and thus cannot contain a message body or trailer
   section(s).
"


The 'selected representation' is being the object that was cached.

Amos


More information about the squid-users mailing list