[squid-users] Squid 4.2 : caching is not working

Amos Jeffries squid3 at treenet.co.nz
Fri Sep 7 17:30:54 UTC 2018

On 8/09/18 4:46 AM, Hariharan Sethuraman wrote:
> Hi team,
> I have created directories using squid -z and then triggered squid -f
> /etc/squid/squid.conf -NYCd 1. Find (1) debug info below. And below (2)
> are the cache directory and squid-config. 
> (1) - debug info:
> squidclient -h localhost cache_object://localhost/ mgr:objects >>> this

You do not need to pass squidclient the cache_object: URLs, nor
localhost as server. Just:

 squidclient mgr:objects

Also, what *exactly* did that report tell you?
 "cache" is more than just the disk storage area.

> was showing the entry when the download was going on and disappeared
> after the download complete(~290MB) on the browser.

What I am thinking reading that is that probably Squid used the cache
storage area as a temporary location for the bytes of a very large
object, but then removed it once the response was completely delivered
since it was not cacheable.

Details matter. The "~" means "approximately" and your config says
*exactly* 300 MByte is the upper limit.

 So an object which is "approximately 290" may in truth be *over* 300
and thus not permitted to cache.

NP: you can use the tool at redbot.org to check URL cacheability. It
will also tell you about any caching related HTTP compliance issues with
that resource.
 Or you can set "debug_options 11,2" in your squid.conf and check the
exact HTTP messages your proxy is dealing with.

 When I checked the
> du of cache directory, it is intact with 200KB

> ..
> cache allow all
> strip_query_terms off

Above are defaults. No need to configure since Squid-3.

> ..
> cache_dir ufs /var/spool/squid/cache 2000 16 256
> maximum_object_size 300 MB
> ..
> range_offset_limit -1
> ..
> url_rewrite_access allow all
> url_rewrite_program  /usr/bin/python /usr/share/proxypass.py

Not relevant, except that when testing the URL like with redbot.org you
need to use the URL this helper produces instead of what was passed into
Squid by the client.

> http_access deny all
> ...
> always_direct deny all
> (a) Please let me know what am missing to enable cache.

Cache is enabled and Squid caches as much as it can by default - within
the limits prescribed by HTTP specification and your config settings.

So the only thing to do is ensure that you do not actively *prevent*
caching from happening somehow.

> (b) Also "squidclient -h localhost cache_object://localhost/
> mgr:objects" hope this command will show the entry even after caching.

It (well, "squidclient mgr:objects") should show all objects currently
known to the proxy. That will mostly be cached objects (both disk and
in-memory), but also included temporary in-transit objects.


More information about the squid-users mailing list