[squid-users] Check if object is already cached

Amos Jeffries squid3 at treenet.co.nz
Wed Dec 10 15:40:14 UTC 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/12/2014 6:04 a.m., Ulises Nicolini wrote:
> Hello,
> 
> I'm working with some scripts to prefetch content but having some 
> trouble, what I can't work out is a way to check if a given object
> is already cached, in other words, I want to check if the object
> I'm going to download is going to hit, in which case I can ignore
> it. I've read squidclient man page but could not find something
> like it
> 

While HIT means cached object was used, an object being in cache does
not mean it will HIT.

An object in cache can be stale, or could be a variant different from
what will be needed in future.

Pre-caching in HTTP has not been of much use since HTTP/1.1 started
getting popular. The HTTP/1.0 concept of HIT/MISS got extended and
expanded to include near-HIT or near-MISS or shared-HIT.

Back to your question... The way to check if an object is in cache is
to fetch it. If it was already there it will be refreshed, and if it
was missing it may now be cached (if cacheable).
 If you want to do the test without risking upstream bandwidth use the
squidclient parameter -H 'Cache-Control:only-if-cached\n' which will
return 200 status only if the cache does contain the object matching
the request.

Amos

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (MingW32)

iQEcBAEBAgAGBQJUiGldAAoJELJo5wb/XPRjfdgIANEiy8Zbo3Yfo64hco//khUI
wf9GHxViAGEH2LmDopDrjxfmHsOjeZoZoeepCGh3NgHgGOaFo0wQAw1uYUd0QBxY
15YzLEyb5WFo/L6BmQM344RolFOrqygY+tNVQabyUWRZ9h0iMahStpOm7TZY44Ih
pPYyByNJLRTiixCtPDtqfCPgc+1dL0ZHjvc+//iw48HIocx9dmv8UEfFPMOsyGO4
+0LBXPvdYG3ccBpXJjJ9fYURR5G7EuTi3lnOvwR4Cf7vJyd8v06qjCK+yT20o6O4
A4MgAvbRN6eLTY9RZ6nnlbzqDmBnS8g19bjedhOkPx8mPWi4xeZWfUF8U8MBIMQ=
=FRb2
-----END PGP SIGNATURE-----


More information about the squid-users mailing list