#
-# $Id: cf.data.pre,v 1.168 2000/03/14 22:59:13 wessels Exp $
+# $Id: cf.data.pre,v 1.169 2000/05/02 18:35:09 hno Exp $
#
#
# SQUID Internet Object Cache http://squid.nlanr.net/Squid/
encrypted. This is the encryption key.
DOC_END
+NAME: nonhierarchical_direct
+TYPE: onoff
+LOC: Config.onoff.nonhierarchical_direct
+DEFAULT: on
+DOC_START
+ By default, Squid will send any non-hierarchical requests
+ (matching hierarchy_stoplist or not cachable request type) direct
+ to origin servers.
+
+ If you set this to off, then Squid will prefer to send these
+ requests to parents.
+
+ Note that in most configurations, by turning this off you will only
+ add latency to these request without any improvement in global hit
+ ratio.
+
+ If you are inside an firewall then see never_direct instead of
+ this directive.
+
+nonhierarchical_direct on
+DOC_END
+
NAME: prefer_direct
TYPE: onoff
LOC: Config.onoff.prefer_direct
-DEFAULT: on
+DEFAULT: off
DOC_START
- By default, if the ICP, HTCP, Cache Digest, etc. techniques
- do not yield a parent cache, Squid gives higher preference
- to forwarding the request direct to origin servers, rather
- than selecting a parent cache anyway.
+ Normally Squid tries to use parents for most requests. If you by some
+ reason like it to first try going direct and only use a parent if
+ going direct fails then set this to off.
+
+ By combining nonhierarchical_direct off and prefer_direct on you
+ can set up Squid to use a parent as a backup path if going direct
+ fails.
- If you want Squid to give higher precedence to a parent
- cache, instead of going direct, then turn this option off.
-prefer_direct on
+prefer_direct off
DOC_END
NAME: strip_query_terms
/*
- * $Id: peer_select.cc,v 1.106 2000/05/02 18:32:41 hno Exp $
+ * $Id: peer_select.cc,v 1.107 2000/05/02 18:35:09 hno Exp $
*
* DEBUG: section 44 Peer Selection Algorithm
* AUTHOR: Duane Wessels
static void peerGetSomeNeighborReplies(ps_state *);
static void peerGetSomeDirect(ps_state *);
static void peerGetSomeParent(ps_state *);
+static void peerGetAllParents(ps_state *);
static void peerAddFwdServer(FwdServer **, peer *, hier_code);
static void
peerGetSomeNeighborReplies(ps);
entry->ping_status = PING_DONE;
}
- if (Config.onoff.prefer_direct)
+ switch (ps->direct) {
+ case DIRECT_YES:
peerGetSomeDirect(ps);
- peerGetSomeParent(ps);
- /* Have direct as a last resort if possible.. */
- peerGetSomeDirect(ps);
+ break;
+ case DIRECT_NO:
+ peerGetSomeParent(ps);
+ peerGetAllParents(ps);
+ break;
+ default:
+ if (Config.onoff.prefer_direct)
+ peerGetSomeDirect(ps);
+ if (request->flags.hierarchical || !Config.onoff.nonhierarchical_direct)
+ peerGetSomeParent(ps);
+ if (!Config.onoff.prefer_direct)
+ peerGetSomeDirect(ps);
+ break;
+ }
peerSelectCallback(ps);
}
}
}
+/* Adds alive parents. Used as a last resort for never_direct.
+ */
+static void
+peerGetAllParents(ps_state * ps)
+{
+ peer *p;
+ request_t *request = ps->request;
+ /* Add all alive parents */
+ for (p = Config.peers; p; p = p->next) {
+ /* XXX: neighbors.c lacks a public interface for enumerating
+ * parents to a request so we have to dig some here..
+ */
+ if (neighborType(p, request) != PEER_PARENT)
+ continue;
+ if (!peerHTTPOkay(p, request))
+ continue;
+ debug(15, 3) ("peerGetAllParents: adding alive parent %s\n", p->host);
+ peerAddFwdServer(&ps->servers, p, ANY_OLD_PARENT);
+ }
+ /* XXX: should add dead parents here, but it is currently
+ * not possible to find out which parents are dead or which
+ * simply are not configured to handle the request.
+ */
+ /* Add default parent as a last resort */
+ if ((p = getDefaultParent(request))) {
+ peerAddFwdServer(&ps->servers, p, DEFAULT_PARENT);
+ }
+}
+
static void
peerPingTimeout(void *data)
{