[squid-users] Enable caching

Alex Rousskov rousskov at measurement-factory.com
Wed Apr 5 13:27:07 UTC 2023


On 4/5/23 06:07, Andrey K wrote:

> Previously, caching was disabled on our proxy servers. Now we need to 
> cache some content (files about 10 MB in size).
> So we changed the squid.conf:

> cache_dir ufs /data/squid/cache 32000 16 256 max-size=12000000
> 
> We have 24 workers on each proxy.

UFS-based cache_dirs are not supported in multi-worker configurations 
and, in most cases, should not be used in such configurations. The 
combination will violate basic HTTP caching rules and may crash Squid 
and/or corrupt responses.


> We saw that some requests were taken from the cache, and some were not.
> The documentation says:
> "In SMP configurations, cache_dir must not precede the workers option 
> and should use configuration macros or conditionals to give each worker 
> interested in disk caching a dedicated cache directory."

The official documentation quoted above is stale and very misleading in 
modern Squids. Ignore it. I will try to find the time to post a PR to 
fix this.


> So we switched to a rock cache_dir:
> cache_dir rock /data/squid/cache 32000 max-size=12000000
> 
> Now everything seems to be working fine in the test environment, but I 
> found limitations on the RockStore 
> (https://wiki.squid-cache.org/Features/RockStore:
> "Objects larger than 32,000 bytes cannot be cached when cache_dirs are 
> shared among workers."

The Feature/RockStore page is stale and can easily mislead. In general, 
Feature/Foo wiki pages are often development-focused and get stale with 
time. They cannot be reliably used as a Squid feature documentation.


> Does this mean that RockStore is not suitable for caching large files?

No, it does not. Rock storage has evolved since that Feature page was 
written. You can see the following wiki page discussing evolved rock 
storage design, but that page probably has some stale info as well:
https://wiki.squid-cache.org/Features/LargeRockStore


> Should I switch back to the UFS and configure 24 cache_dirs

If everything is "working fine", then you should not. Otherwise, I 
recommend discussing specific problems before switching to that 
unsupported and dangerous hack.


HTH,

Alex.



More information about the squid-users mailing list