[squid-users] Use of conditionals in config file

Amos Jeffries squid3 at treenet.co.nz
Tue Jul 7 15:40:07 UTC 2015


On 8/07/2015 3:03 a.m., Ulises Nicolini wrote:
> Hello,
> 
> Is there any way to do something like this?
> 
> if ${process_number} = 2 && url_regex facebook.com.*
> 
>     cache_dir aufs /cache_face   590000  32 256 min-size=500
> max-size=576000
> endif
> 
> 
> Of course this is not valid syntax config , but the idea is to store in
> a certain cache_dir only the content from a given domain (i.e
> facebook.com.*)

What you are thinking is this:

 if ${process_number} = 2
  acl FB dstdomain facebook.com
  cache deny !FB
  cache_dir ...
 endif


However it makes no sense to do.

Firstly, an HTTP proxy cache is just a temporary buffer in the network
path between client and origin server. Segregating temporary storage
location based on arbitrary origins gains no benefit over non-segregated
data, and costs extra processing time to figure out the special vs
non-special locations for every request.

Secondly, caches do not store content by domain name. Content is stored
by an efficient hash of the URL plus various other details specific to
the object type. One of which is how closely related in time any two
given requests occured, such that sites built as a mashup of references
to other domains content will render as quickly. Segregation by domain
defeats that algorithm. NP: Facebook is one of those types of site.

Thirdly, disk is only one layer of a multi-layered caching system.
Objects have been through both the in-transit storage and memory cache
and remained cacheable before they get considered for saving to disk
locations.

Amos



More information about the squid-users mailing list