#!/usr/local/bin/perl
$|=1;
print while (<>);
The redirector program must read URLs (one per line) on standard input,
and write rewritten URLs or blank lines on standard output. Note that
the redirector program can not use buffered I/O. Squid writes
additional information after the URL which a redirector can use to make
a decision. The input line consists of four fields:
URL ip-address/fqdn ident method
The ip-address is always given, the fqdn and ident fields will be given if
available, or will be "-" otherwise. Note that the ident value will only
be available if 'ident_lookup' in enabled in the config file. The
requestrequest method is GET, POST, etc.
http://192.0.0.1/foo
http://192.0.0.2/foo
The redirector program might be this Perl script:
#!/usr/local/bin/perl
$|=1;
while (<>) {
s@http://192\.0\.0\.1@http://www1.foo.org@;
s@http://192\.0\.0\.2@http://www2.foo.org@;
print;
}
You may receive statistics on the redirector usage by requesting the
following 'cache_object' URL:
% client cache_object://localhost/stats/redirector
acl Myusers srcdomain foo.org
The use of this ACL type may cause noticeable delay in serving objects
through the cache. However, so long as allowed clients are local, the
reverse lookup should not take very long and the delay may not be
noticed.
acl BadClients srcdomain none
http_access deny BadClients
NOTE: DNS has a number of known security problems. Squid does not make
any effort to guarantee the validity of data returned from gethostbyname()
or gethostbyaddr() calls.
given: DS = amount of 'cache_swap' / number of 'cache_dir's OS = avg object size = 20k NO = objects per L2 directory = 256 calculate: L1 = number of L1 directories L2 = number of L2 directories such that: L1 x L2 = DS / OS / NO
diff -ru bind-4.9.4-orig/res/gethnamaddr.c bind-4.9.4/res/gethnamaddr.c
--- bind-4.9.4-orig/res/gethnamaddr.c Mon Aug 5 02:31:35 1996
+++ bind-4.9.4/res/gethnamaddr.c Tue Aug 27 15:33:11 1996
@@ -133,6 +133,7 @@
} align;
extern int h_errno;
+int _dns_ttl_;
#ifdef DEBUG
static void
@@ -223,6 +224,7 @@
host.h_addr_list = h_addr_ptrs;
haveanswer = 0;
had_error = 0;
+ _dns_ttl_ = -1;
while (ancount-- > 0 && cp < eom && !had_error) {
n = dn_expand(answer->buf, eom, cp, bp, buflen);
if ((n < 0) || !(*name_ok)(bp)) {
@@ -232,8 +234,11 @@
cp += n; /* name */
type = _getshort(cp);
cp += INT16SZ; /* type */
- class = _getshort(cp);
- cp += INT16SZ + INT32SZ; /* class, TTL */
+ class = _getshort(cp);
+ cp += INT16SZ; /* class */
+ if (qtype == T_A && type == T_A)
+ _dns_ttl_ = _getlong(cp);
+ cp += INT32SZ; /* TTL */
n = _getshort(cp);
cp += INT16SZ; /* len */
if (class != C_IN) {
cache_host parent cache.foo.org 3128 3130 neighbor_type_domain cache.foo.org sibling .com .net neighbor_type_domain cache.foo.org sibling .au .deNote that neighbor_type_domain is totally separate from the cache_host_domain option (which controls whether or not to query the neighbor). In the absence of cache_host_domain restrictions, the neighbor cache.foo.org will be queried for all requests.
AGE is how much the object has aged *since* it was retrieved:
AGE = NOW - OBJECT_DATE
LM_AGE is how old the object was *when* it was retrieved:
LM_AGE = OBJECT_DATE - LAST_MODIFIED_TIME
LM_FACTOR is the ratio of AGE to LM_AGE:
LM_FACTOR = AGE / LM_AGE
CLIENT_MAX_AGE is the (optional) maximum object age the client will
accept as taken from the HTTP/1.1 Cache-Control request header.
EXPIRES is the (optional) expiry time from the server reply headers.
These values are compared with the parameters of the 'refresh_pattern'
rules. The refresh parameters are:
if (CLIENT_MAX_AGE)
if (AGE > CLIENT_MAX_AGE)
return STALE
if (AGE <= MIN_AGE)
return FRESH
if (EXPIRES) {
if (EXPIRES <= NOW)
return STALE
else
return FRESH
}
if (AGE > MAX_AGE)
return STALE
if (LM_FACTOR < PERCENT)
return FRESH
return STALE
Note that the Max-Age in a client request takes the highest precedence.
The 'MIN' value should normally be set to zero since it has higher
precedence than the server's Expires: value. But if you wish to
override the Expires: headers, you may use the MIN value.
Forwarded: by cache-host for client-address
Current HTTP/1.1 draft documents instead use the "Via" header, but it
does not provide any standard way of indicating the client address
in the request. Since a number of people missed having the originating
client address in the request, Squid now adds its own request header
called "X-Forwarded-For" which looks like this:
X-Forwarded-For: 128.138.243.150, unknown, 192.52.106.30
Entries are always IP addresses, or the word "unknown" if the address
could not be determined or if it has been disabled with the
'forwarded_for' configuration option.
Network recv/sent RTT Hops Hostnames
192.41.10.0 20/ 21 82.3 6.0 www.jisedu.org www.dozo.com
bo.cache.nlanr.net 42.0 7.0
uc.cache.nlanr.net 48.0 10.0
pb.cache.nlanr.net 55.0 10.0
it.cache.nlanr.net 185.0 13.0
WARNING: Exceeded 'cache_mem' size (4122K > 4096K)
If this warning occurs frequently then you need to consider either
increasing the 'cache_mem' value or decreasing the
'maximum_object_size' value. If the cache_mem usage is above the low
water mark, then Squid will check for objects larger than
'maximum_object_size.' Any such objects are put into "delete behind"
mode which means Squid releases the section of the object which has
been delivered to all clients reading from it.
cache_host N1 sibling 3128 3130
cache_host N2 sibling 3128 3130
cache_host N3 sibling 3128 3130
cache_host P1 parent 3128 3130 no-query default
will result in ICP queries to sibling caches N1, N2, and N3. If none
of the siblings has the requested object then it will be retrieved
through parent P1 due to the 'default' designation. Note that
'default' does not conflict with any 'cache_host_domain' restrictions
which might be placed on a neighbor.
cache_swap store_avg_object_size # default 20K store_objects_per_bucket # default 20We first estimate the number of objects your cache can hold:
store_buckets store_maintain_rate 7951 10 sec 12149 7 sec 16231 5 sec 33493 2 sec 65357 1 secIf you want to increase the maintenance rate then decrease the store_objects_per_bucket parameter.