<!doctype linuxdoc system>

<article>

<titlepag>
<TITLE>SQUID Frequently Asked Questions</TITLE>
<author>&copy; 2001 Duane Wessels, <tt/wessels@squid-cache.org/
<abstract>
Frequently Asked Questions (with answers!) about the Squid Internet
Object Cache software.
</abstract>
</titlepag>

<toc>

<p>
You can download the FAQ as
<url url="FAQ.pdf" name="PDF">, 
<url url="FAQ.ps.gz" name="compressed Postscript">, 
<url url="FAQ.txt" name="plain text">,
<url url="FAQ.sgml" name="linuxdoc SGML source"> or as a
<url url="FAQ.tar.gz" name="compressed tar of HTML">.
</p>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<sect>About Squid, this FAQ, and other Squid information resources

<sect1>What is Squid?
<P>
Squid is a high-performance proxy caching server for web clients,
supporting FTP, gopher, and HTTP data objects.  Unlike traditional
caching software, Squid handles all requests in a single,
non-blocking, I/O-driven process.

Squid keeps
meta data and especially hot objects cached in RAM, caches
DNS lookups, supports non-blocking DNS lookups, and implements
negative caching of failed requests.

Squid supports SSL, extensive
access controls, and full request logging.  By using the
lightweight Internet Cache Protocol, Squid caches can be arranged
in a hierarchy or mesh for additional bandwidth savings.

<P>
Squid consists of a main server program <em/squid/, a Domain Name System
lookup program <em/dnsserver/, some optional programs for rewriting
requests and performing authentication, and some management and client
tools.  When <em/squid/ starts up, it spawns a configurable number of
<em/dnsserver/ processes, each of which can perform a single, blocking
Domain Name System (DNS) lookup.  This reduces the amount of time the
cache waits for DNS lookups.

<P>
Squid is derived from the ARPA-funded
<url	url="http://webharvest.sourceforge.net/ng/"
	name="Harvest project">.

<sect1>What is Internet object caching?
<P>
Internet object caching is a way to store requested Internet objects
(i.e., data available via the HTTP, FTP, and gopher protocols) on a
system closer to the requesting site than to the source. Web browsers
can then use the local Squid cache as a proxy HTTP server, reducing
access time as well as bandwidth consumption.

<sect1>Why is it called Squid?
<P>
Harris' Lament says, ``All the good ones are taken."

<P>
We needed to distinguish this new version from the Harvest
cache software.  Squid was the code name for initial
development, and it stuck.

<sect1>What is the latest version of Squid?
<P>
Squid is updated often; please see
<url	url="http://www.squid-cache.org/"
	name="the Squid home page">
for the most recent versions.

<sect1>Who is responsible for Squid?
<P>
Squid is the result of efforts by numerous individuals from
the Internet community.
<url	url="mailto:wessels@squid-cache.org"
	name="Duane Wessels">
of the National Laboratory for Applied Network Research (funded by
the National Science Foundation) leads code development.
Please see
<url	url="http://www.squid-cache.org/CONTRIBUTORS"
	name="the CONTRIBUTORS file">
for a list of our excellent contributors.

<sect1>Where can I get Squid?
<P>
You can download Squid via FTP from
<url	url="ftp://ftp.squid-cache.org/pub/"
	name="the primary FTP site">
or one of the many worldwide
<url	url="http://www.squid-cache.org/mirrors.html"
	name="mirror sites">.

<P>
Many sushi bars also have Squid.

<sect1>What Operating Systems does Squid support?
<P>
The software is designed to operate on any modern Unix system, and
is known to work on at least the following platforms:
<itemize>
<item> Linux
<item> FreeBSD
<item> NetBSD
<item> OpenBSD
<item> BSDI
<item> Mac OS/X
<item> OSF/Digital Unix/Tru64
<item> IRIX
<item> SunOS/Solaris
<item> NeXTStep
<item> SCO Unix
<item> AIX
<item> HP-UX
<item> <ref id="building-os2" name="OS/2">
</itemize>

<P>
For more specific information, please see
<url url="http://www.squid-cache.org/platforms.html" name="platforms.html">.
If you encounter any platform-specific problems, please
let us know by registering a entry in our
<url	url="http://www.squid-cache.org/bugs/"
	name="bug database">.

<sect1>Does Squid run on Windows NT?
<label id="squid-NT">
<P>
Recent versions of Squid will <em/compile and run/ on Windows/NT
with the
<url url="http://www.cygwin.com/" name="Cygwin"> /
<url url="http://www.mingw.org/" name="Mingw"> packages.

<p>
<url url="http://www.acmeconsulting.it/SquidNT/" name="Guido Serassio">
maintains the native NT port of Squid and is actively working on having the needed changes integrated into the standard Squid distribution. Partially based on earlier NT port by <url url="http://www.phys-iasi.ro/users/romeo/squidnt.htm" name="Romeo Anghelache">.

<p>
<url url="http://www.logisense.com/" name="LogiSense">
has ported Squid to Windows NT and sells a supported
version.  You can also download the source from
<url url="ftp://ftp.logisense.com/cachexpress/" name="their FTP site">.
Thanks to LogiSense for making the code available as required by the GPL terms.

<sect1>What Squid mailing lists are available?
<P>
<itemize>
<item> squid-users@squid-cache.org: general discussions about the
Squid cache software. Subscribe via
<it/squid-users-subscribe@squid-cache.org/.

Previous messages are available for browsing at
<url	url="http://www.squid-cache.org/mail-archive/squid-users/"
	name="the Squid Users Archive">,
and also at <url url="http://marc.theaimsgroup.com/?l=squid-users&amp;r=1&amp;w=2" name="theaimsgroup.com">.

<item>
squid-users-digest: digested (daily) version of
above.  Subscribe via
<it/squid-users-digest-subscribe@squid-cache.org/.

<item>
squid-announce@squid-cache.org: A receive-only list for
announcements of new versions.
Subscribe via
<it/squid-announce-subscribe@squid-cache.org/.

<item>
<it/squid-bugs@squid-cache.org/:
A closed list for sending us bug reports.
Bug reports received here are given priority over
those mentioned on squid-users.

<item>
<it/squid@squid-cache.org/:
A closed list for sending us feed-back and ideas.

<item>
<it/squid-faq@squid-cache.org/:
A closed list for sending us feed-back, updates, and additions to
the Squid FAQ.
</itemize>

<P>
We also have a few other mailing lists which are not strictly
Squid-related.

<itemize>
<item>
<it/cache-snmp@ircache.net/:
A public list for discussion of Web Caching and SNMP issues and developments.
Eventually we hope to put forth a standard Web Caching MIB.

<item>
<it/icp-wg@ircache.net/:
Mostly-idle mailing list for the nonexistent ICP Working Group within
the IETF.  It may be resurrected some day, you never know!

</itemize>

<sect1>I can't figure out how to unsubscribe from your mailing list.
<P>
All of our mailing lists have ``-subscribe'' and ``-unsubscribe''
addresses that you must
use for subscribe and unsubscribe requests.  To unsubscribe from
the squid-users list, you send a message to <em/squid-users-unsubscribe@squid-cache.org/.

<sect1>What other Squid-related documentation is available?
<p>
<itemize>

<item>
<url url="http://www.squid-cache.org/" name="The Squid home page">
for information on the Squid software

<item>
<url url="http://squidbook.org/" name="Squid: The Definitive Guide">
to be published by
<url url="http://www.oreilly.com/catalog/squid/" name="O'Reilly and Associates">January 2004.

<item>
<url url="http://www.ircache.net/" name="The IRCache Mesh">
gives information on our operational mesh of caches.

<item>
<url url="http://www.squid-cache.org/Doc/FAQ/" name="The Squid FAQ"> (uh, you're reading it).

<item>
<url url="http://squid-docs.sourceforge.net/latest/html/book1.html" name="Oskar's Squid Users Guide">.

<item>
<url url="http://www.visolve.com/squidman/Configuration Guide.html" name="Visolve's Configuration Guide">.

<item>
Squid documentation in
<url url="http://www.squid-handbuch.de/" name="German">,
<url url="http://istanbul.linux.org.tr/~ilkerg/squid/elkitabi.html" name="Turkish">,
<url url="http://merlino.merlinobbs.net/Squid-Book/" name="Italian">,
<url url="http://www.linuxman.pro.br/squid/" name="Brazilian Portugese">, and another in
<url url="http://www.geocities.com/glasswalk3r/linux/squidnomicon.html" name="Brazilian Portugese">.

<item>
<url url="http://www.squid-cache.org/Doc/Prog-Guide/prog-guide.html" name="Squid Programmers Guide">.
Yeah, its extremely incomplete.  I assure you this is the most recent version.

<item>
<url url="http://www.web-cache.com" name="Web Caching Resources">

<item><url url="/Versions/1.0/Release-Notes-1.0.txt" name="Squid-1.0 Release Notes">
<item><url url="/Versions/1.1/Release-Notes-1.1.txt" name="Squid-1.1 Release Notes">
<item><url url="http://www.squid-cache.org/Doc/Hierarchy-Tutorial/" name="Tutorial on Configuring Hierarchical Squid Caches">
<item><url url="ftp://ftp.isi.edu/in-notes/rfc2616.txt" name="RFC 2186"> ICPv2 -- Protocol
<item><url url="ftp://ftp.isi.edu/in-notes/rfc2187.txt" name="RFC 2187"> ICPv2 -- Application
<item><url url="ftp://ftp.isi.edu/in-notes/rfc1016.txt" name="RFC 1016">
</itemize>

<sect1>Does Squid support SSL/HTTPS/TLS?
<p>
As of version 2.5, Squid can terminate SSL connections.  This is perhaps
only useful in a surrogate (http accelerator) configuration.  You must
run configure with <em/--enable-ssl/.  See <em/https_port/ in
squid.conf for more information.

<P>
Squid also supports these encrypted protocols by ``tunelling''
traffic between clients and servers.  In this case, Squid can relay
the encrypted bits between a client and a server.
<p>

Normally, when your browser comes across an <em/https/ URL, it
does one of two things:

<enum>
<item>The browser opens an SSL connection directly to the origin
server.
<item>The browser tunnels the request through Squid with the
<em/CONNECT/ request method.
</enum>
<p>
The <em/CONNECT/ method is a way to tunnel any kind of
connection through an HTTP proxy.  The proxy doesn't 
understand or interpret the contents.  It just passes 
bytes back and forth between the client and server.
For the gory details on tunnelling and the CONNECT
method, please see
<url url="ftp://ftp.isi.edu/in-notes/rfc2817.txt" name="RFC 2817">
and <url url="http://www.web-cache.com/Writings/Internet-Drafts/draft-luotonen-web-proxy-tunneling-01.txt"
name="Tunneling TCP based protocols through Web proxy servers"> (expired).


<sect1>What's the legal status of Squid?
<P>
Squid is <url url="squid-copyright.txt" name="copyrighted">
by the University of California San Diego.
Squid uses some <url url="squid-credits.txt" name="code developed by others">.

<P>
Squid is
<url url="http://www.gnu.org/philosophy/free-sw.html"
name="Free Software">.

<P>
Squid is licensed under the terms of the
<url url="http://www.gnu.org/copyleft/gpl.html"
name="GNU General Public License">.

<sect1>Is Squid year-2000 compliant?
<P>
We think so.  Squid uses the Unix time format for all internal time
representations.  Potential problem areas are in printing and
parsing other time representations.  We have made the following
fixes in to address the year 2000:
<itemize>
<item>
	<em/cache.log</em> timestamps use 4-digit years instead of just 2 digits.
<item>
	<em/parse_rfc1123()/ assumes years less than "70" are after 2000.
<item>
	<em/parse_iso3307_time()/ checks all four year digits.

</itemize>

<P>
Year-2000 fixes were applied to the following Squid versions:
<itemize>
<item>
<url url="/Versions/v2/2.1/" name="squid-2.1">:
Year parsing bug fixed for dates in the "Wed Jun  9 01:29:59 1993 GMT"
format (Richard Kettlewell).
<item>
squid-1.1.22:
Fixed likely year-2000 bug in ftpget's timestamp parsing (Henrik Nordstrom).
<item>
squid-1.1.20:
Misc fixes (Arjan de Vet).
</itemize>

<P>Patches:
<itemize>
<item>
<url url="../Y2K/patch3" name="Richard's lib/rfc1123.c patch">.
If you are still running 1.1.X, then you should apply this patch to
your source and recompile.
<item>
<url url="../Y2K/patch2" name="Henrik's src/ftpget.c patch">.
<item>
<url url="../Y2K/patch1" name="Arjan's lib/rfc1123.c patch">.
</itemize>

<p>
Squid-2.2 and earlier versions have a <url
url="http://www.squid-cache.org/Versions/v2/2.2/bugs/index.html#squid-2.2.stable5-mkhttpdlogtime-end-of-year" name="New
Year bug">.  This is not strictly a Year-2000 bug; it would happen on the first day of any year.

<sect1>Can I pay someone for Squid support?
<P>
Yep.  Please see the <url url="/Support/services.html"
name="commercial support page">.


<sect1>Squid FAQ contributors
<P>
The following people have made contributions to this document:
<itemize>
<item>
<url url="mailto:dpnava@mozcom.com" name="Dodjie Nava">
<item>
<url url="mailto:JLarmour@origin-at.co.uk" name="Jonathan Larmour">
<item>
<url url="mailto:cord@Wunder-Nett.org" name="Cord Beermann">
<item>
<url url="mailto:tony@nlanr.net" name="Tony Sterrett">
<item>
<url url="mailto:ghynes@compusult.nf.ca" name="Gerard Hynes">
<item>
<url url="mailto:tkatayam@pi.titech.ac.jp" name="Katayama, Takeo">
<item>
<url url="mailto:wessels@ircache.net" name="Duane Wessels">
<item>
<url url="mailto:kc@caida.org" name="K Claffy">
<item>
<url url="mailto:pauls@etext.org" name="Paul Southworth">
<item>
<url url="mailto:oskar@is.co.za" name="Oskar Pearson">
<item>
<url url="mailto:ongbh@zpoprp.zpo.dec.com" name="Ong Beng Hui">
<item>
<url url="mailto:torsten.sturm@axis.de" name="Torsten Sturm">
<item>
<url url="mailto:jrg@blodwen.demon.co.uk" name="James R Grinter">
<item>
<url url="mailto:roever@nse.simac.nl" name="Rodney van den Oever">
<item>
<url url="mailto:bertold@tohotom.vein.hu" name="Kolics Bertold">
<item>
<url url="mailto:carson@cugc.org" name="Carson Gaspar">
<item>
<url url="mailto:michael@metal.iinet.net.au" name="Michael O'Reilly">
<item>
<url url="mailto:hclsmith@tallships.istar.ca" name="Hume Smith">
<item>
<url    url="mailto:RichardA@noho.co.uk" name="Richard Ayres">
<item>
<url url="mailto:John.Saunders@scitec.com.au" name="John Saunders">
<item>
<url url="mailto:miquels@cistron.nl" name="Miquel van Smoorenburg">
<item>
<url url="mailto:david@avarice.nepean.uws.edu.au" name="David J N Begley">
<item>
<url url="mailto:SarKev@topnz.ac.nz" name="Kevin Sartorelli">
<item>
<url url="mailto:doering@usf.uni-kassel.de" name="Andreas Doering">
<item>
<url url="mailto:mark@cal026031.student.utwente.nl" name="Mark Visser">
<item>
<url url="mailto:tom@interact.net.au" name="tom minchin">
<item>
<url url="mailto:voeckler@rvs.uni-hannover.de" name="Jens-S. V&ouml;ckler">
<item>
<url url="mailto:andre.albsmeier@mchp.siemens.de" name="Andre Albsmeier">
<item>
<url url="mailto:nazard@man-assoc.on.ca" name="Doug Nazar">
<item>
<url url="mailto:hno@squid-cache.org" name="Henrik Nordstrom">
<item>
<url url="mailto:mark@rts.com.au" name="Mark Reynolds">
<item>
<url url="mailto:Arjan.deVet@adv.IAEhv.nl" name="Arjan de Vet">
<item>
<url url="mailto:peter@spinner.dialix.com.au" name="Peter Wemm">
<item>
<url url="mailto:webadm@info.cam.ac.uk" name="John Line">
<item>
<url url="mailto:ARMISTEJ@oeca.otis.com" name="Jason Armistead">
<item>
<url url="mailto:cudch@csv.warwick.ac.uk" name="Chris Tilbury">
<item>
<url url="mailto:jeff@sisna.com" name="Jeff Madison">
<item>
<url url="mailto:mbatchelor@citysearch.com" name="Mike Batchelor">
<item>
<url url="mailto:bogstad@pobox.com" name="Bill Bogstad">
<item>
<url url="mailto:radu at netsoft dot ro" name="Radu Greab">
<item>
<url url="mailto:f.j.bosscha@nhl.nl" name="F.J. Bosscha">
<item>
<url url="mailto:signal@shreve.net" name="Brian Feeny">
<item>
<url url="mailto:Support@dnet.co.uk" name="Martin Lyons">
<item>
<url url="mailto:david@luyer.net" name="David Luyer">
<item>
<url url="mailto:chris@senet.com.au" name="Chris Foote">
<item>
<url url="mailto:elkner@wotan.cs.Uni-Magdeburg.DE" name="Jens Elkner">
<item>
<url url="mailto:simon@mtds.com" name="Simon White">
<item>
<url url="mailto: jmurdoc at itraktech dot com" name="Jerry Murdock">
<item>
<url url="mailto: geviston at bigpond dot net dot au" name="Gerard Eviston">
<item>
<url url="mailto: rob at poeweb dot com" name="Rob Poe">
</itemize>
<P>
Please send corrections, updates, and comments to:
<url	url="mailto:squid-faq@squid-cache.org"
	name="squid-faq@squid-cache.org">.

<sect1>About This Document
<P>
This document is copyrighted (2000) by Duane Wessels.

<P>
This document was written in SGML and converted with the
<url url="http://www.sgmltools.org/"
     name="SGML-Tools package">.

<P>
Most current version of this document can always be found at
<url url="http://www.squid-cache.org/Doc/FAQ/" name="http://www.squid-cache.org/Doc/FAQ/"> in HTML, Plain Text, Postscript and SGML formats.

<sect2>Want to contribute?  Please write in SGML...

<P>
It is easier for us if you send us text which is close to "correct" SGML.
The SQUID FAQ currently uses the LINUXDOC DTD.  Its probably easiest
to follow examples in the this file.
Here are the basics:

<P>
Use the &lt;url&gt; tag for links, instead of HTML &lt;A HREF ...&gt;
<verb>
	&lt;url url="http://www.squid-cache.org" name="Squid Home Page"&gt;
</verb>

<P>
Use &lt;em&gt; for emphasis, config options, and pathnames:
<verb>
	&lt;em&gt;usr/local/squid/etc/squid.conf&lt;/em&gt;
	&lt;em/cache_peer/
</verb>

<P>
Here is how you do lists:
<verb>
	&lt;itemize&gt;
	&lt;item&gt;foo
	&lt;item&gt;bar
	&lt;/itemize&gt;
</verb>

<P>
Use &lt;verb&gt;, just like HTML's &lt;PRE&gt; to show
unformatted text.

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<sect>Getting and Compiling Squid
<label id="compiling">

<sect1>Which file do I download to get Squid?
<P>
You must download a source archive file of the form
squid-x.y.z-src.tar.gz (eg, squid-1.1.6-src.tar.gz) from
<url	url="http://www.squid-cache.org/"
	name="the Squid home page">, or.
<url	url="ftp://www.squid-cache.org/pub/"
	name="the Squid FTP site">.
Context diffs are available for upgrading to new versions.
These can be applied with the <em/patch/ program (available from
<url	url="ftp://ftp.gnu.org/gnu/patch"
	name="the GNU FTP site">).

<sect1>How do I compile Squid?

<P>
For <bf/Squid-1.0/ and <bf/Squid-1.1/ versions, you can just
type <em/make/ from the top-level directory after unpacking
the source files.  For example:
<verb>
	% tar xzf squid-1.1.21-src.tar.gz
	% cd squid-1.1.21
	% make
</verb>
<P>
For <bf/Squid-2/ you must run the <em/configure/ script yourself
before running <em/make/:
<verb>
	% tar xzf squid-2.0.RELEASE-src.tar.gz
	% cd squid-2.0.RELEASE
	% ./configure
	% make
</verb>

<sect1>What kind of compiler do I need?
<P>
To compile Squid, you will need an ANSI C compiler.  Almost all
modern Unix systems come with pre-installed compilers which work
just fine.  The old <em/SunOS/ compilers do not have support for ANSI
C, and the Sun compiler for <em/Solaris/ is a product which
must be purchased separately.

<P>
If you are uncertain about your system's C compiler, The GNU C compiler is
available at
<url	url="ftp://ftp.gnu.org/gnu/gcc"
	name="the GNU FTP site">.
In addition to gcc, you may also want or need to install the <em/binutils/
package.

<sect1>What else do I need to compile Squid?
<p>
You will need <url url="http://www.perl.com/" name="Perl"> installed
on your system.

<sect1>Do you have pre-compiled binaries available?
<!-- Binaries list replicated at /binaries.html -->

<P>
The developers do not have the resources to make pre-compiled
binaries available.  Instead, we invest effort into making
the source code very portable.  Some people have made
binary packages available.  Please see our
<url url="http://www.squid-cache.org/platforms.html" name="Platforms Page">.

<p>
The <url url="http://freeware.sgi.com/" name="SGI Freeware"> site
has pre-compiled packages for SGI IRIX.

<p> 
Squid binaries for
<url url="http://www.freebsd.org/cgi/ports.cgi?query=squid-2&amp;stype=all"
name="FreeBSD on Alpha and Intel">.

<p>
Squid binaries for
<url url="ftp://ftp.netbsd.org/pub/NetBSD/packages/pkgsrc/www/squid/README.html"
name="NetBSD on everything">

<p>
Gurkan Sengun has some
<url url="http://www.linuks.mine.nu/solaris/" name="Sparc/Solaris packages">
available.

<sect1>How do I apply a patch or a diff?
<P>
You need the <tt/patch/ program.  You should probably duplicate the
entire directory structure before applying the patch.  For example, if
you are upgrading from squid-1.1.10 to 1.1.11, you would run
these commands:
<verb>
	cd squid-2.5.STABLE3
	mkdir ../squid-2.5.STABLE4
	find . -depth -print | cpio -pdv ../squid-1.1.11
	cd ../squid-1.1.11
	patch -p1 &lt; /tmp/squid-2.5.STABLE3-STABLE4.diff

or alternatively

	cp -rl squid-2.5.STABLE3 squid-2.5.STABLE4
	cd squid-2.5.STABLE4
	zcat /tmp/squid-2.5.STABLE3-STABLE4.diff.gz | patch -p1
</verb>
After the patch has been applied, you must rebuild Squid from the
very beginning, i.e.:
<verb>
	make distclean
	./configure ...
	make
	make install
</verb>

<P>
If your <tt/patch/ program seems to complain or refuses to work,
you should get a more recent version, from the
<url	url="ftp://ftp.gnu.ai.mit.edu/pub/gnu/"
	name="GNU FTP site">, for example.

<sect1><em/configure/ options
<P>
The configure script can take numerous options.  The most
useful is <tt/--prefix/ to install it in a different directory.
The default installation directory is <em>/usr/local/squid/</em>.  To
change the default, you could do:
<verb>
	% cd squid-x.y.z
	% ./configure --prefix=/some/other/directory/squid
</verb>

<P>
Type
<verb>
	% ./configure --help
</verb>
to see all available options.  You will need to specify some
of these options to enable or disable certain features.
Some options which are used often include:

<verb>
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local/squid]
  --enable-dlmalloc[=LIB] Compile & use the malloc package by Doug Lea
  --enable-gnuregex       Compile GNUregex
  --enable-splaytree      Use SPLAY trees to store ACL lists
  --enable-xmalloc-debug  Do some simple malloc debugging
  --enable-xmalloc-debug-trace
                          Detailed trace of memory allocations
  --enable-xmalloc-statistics
                          Show malloc statistics in status page
  --enable-carp           Enable CARP support
  --enable-async-io       Do ASYNC disk I/O using threads
  --enable-icmp           Enable ICMP pinging
  --enable-delay-pools    Enable delay pools to limit bandwith usage
  --enable-mem-gen-trace  Do trace of memory stuff
  --enable-useragent-log  Enable logging of User-Agent header
  --enable-kill-parent-hack
                          Kill parent on shutdown
  --enable-snmp           Enable SNMP monitoring
  --enable-cachemgr-hostname[=hostname]
                          Make cachemgr.cgi default to this host
  --enable-arp-acl        Enable use of ARP ACL lists (ether address)
  --enable-htpc           Enable HTCP protocol
  --enable-forw-via-db    Enable Forw/Via database
  --enable-cache-digests  Use Cache Digests
                          see http://www.squid-cache.org/Doc/FAQ/FAQ-16.html
  --enable-err-language=lang
                          Select language for Error pages (see errors dir)
</verb>

<sect1>undefined reference to __inet_ntoa

<P>
by <url	url="mailto:SarKev@topnz.ac.nz" name="Kevin Sartorelli">
and <url url="mailto:doering@usf.uni-kassel.de" name="Andreas Doering">.

<P>
Probably you've recently installed bind 8.x.  There is a mismatch between
the header files and DNS library that Squid has found.  There are a couple
of things you can try.

<P>
First, try adding <tt/-lbind/ to <em/XTRA_LIBS/  in <em>src/Makefile</em>.
If <tt/-lresolv/ is already there, remove it.

<P>
If that doesn't seem to work, edit your <em>arpa/inet.h</em> file and comment out the following:

<verb>
	#define inet_addr               __inet_addr
	#define inet_aton               __inet_aton
	#define inet_lnaof              __inet_lnaof
	#define inet_makeaddr           __inet_makeaddr
	#define inet_neta               __inet_neta
	#define inet_netof              __inet_netof
	#define inet_network            __inet_network
	#define inet_net_ntop           __inet_net_ntop
	#define inet_net_pton           __inet_net_pton
	#define inet_ntoa               __inet_ntoa
	#define inet_pton               __inet_pton
	#define inet_ntop               __inet_ntop
	#define inet_nsap_addr          __inet_nsap_addr
	#define inet_nsap_ntoa          __inet_nsap_ntoa
</verb>

<sect1>How can I get true DNS TTL info into Squid's IP cache?
<label id="dns-ttl-hack">
<P>
If you have source for BIND, you can modify it as indicated in the diff
below.  It causes the global variable _dns_ttl_ to be set with the TTL
of the most recent lookup.  Then, when you compile Squid, the configure
script will look for the _dns_ttl_ symbol in libresolv.a.  If found,
dnsserver will return the TTL value for every lookup.
<P>
This hack was contributed by
<url	url="mailto:bne@CareNet.hu" name="Endre Balint Nagy">.

<verb>
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-- &gt; 0 &amp;&amp; cp &lt; eom &amp;&amp; !had_error) {
                n = dn_expand(answer-&gt;buf, eom, cp, bp, buflen);
                if ((n &lt; 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  &amp;&amp; type == T_A)
+                       _dns_ttl_ = _getlong(cp);
+               cp += INT32SZ;                  /* TTL */
                n = _getshort(cp);
                cp += INT16SZ;                  /* len */
                if (class != C_IN) {
</verb>

<P>
And here is a patch for BIND-8:
<verb>
*** src/lib/irs/dns_ho.c.orig	Tue May 26 21:55:51 1998
--- src/lib/irs/dns_ho.c	Tue May 26 21:59:57 1998
***************
*** 87,92 ****
--- 87,93 ----
  #endif

  extern int h_errno;
+ int _dns_ttl_;

  /* Definitions. */

***************
*** 395,400 ****
--- 396,402 ----
  	pvt-&gt;host.h_addr_list = pvt-&gt;h_addr_ptrs;
  	haveanswer = 0;
  	had_error = 0;
+ 	_dns_ttl_ = -1;
  	while (ancount-- &gt; 0 &amp;&amp; cp &lt; eom &amp;&amp; !had_error) {
  		n = dn_expand(ansbuf, eom, cp, bp, buflen);
  		if ((n &lt; 0) || !(*name_ok)(bp)) {
***************
*** 404,411 ****
  		cp += n;			/* name */
  		type = ns_get16(cp);
   		cp += INT16SZ;			/* type */
! 		class = ns_get16(cp);
!  		cp += INT16SZ + INT32SZ;	/* class, TTL */
  		n = ns_get16(cp);
  		cp += INT16SZ;			/* len */
  		if (class != C_IN) {
--- 406,416 ----
  		cp += n;			/* name */
  		type = ns_get16(cp);
   		cp += INT16SZ;			/* type */
! 		class = _getshort(cp);
!   		cp += INT16SZ;                  /* class */
! 		if (qtype == T_A  &amp;&amp; type == T_A)
! 			_dns_ttl_ = _getlong(cp);
! 		cp += INT32SZ;                  /* TTL */
  		n = ns_get16(cp);
  		cp += INT16SZ;			/* len */
  		if (class != C_IN) {
</verb>

<sect1>My platform is BSD/OS or BSDI and I can't compile Squid
<label id="bsdi-compile">
<P>
<verb>
	cache_cf.c: In function `parseConfigFile':
	cache_cf.c:1353: yacc stack overflow before `token'
	...
</verb>

<P>
You may need to upgrade your gcc installation to a more recent version.
Check your gcc version with
<verb>
	gcc -v
</verb>
If it is earlier than 2.7.2, you might consider upgrading.


<sect1>Problems compiling <em/libmiscutil.a/ on Solaris
<P>
The following error occurs on Solaris systems using gcc when the Solaris C
compiler is not installed:
<verb>
	/usr/bin/rm -f libmiscutil.a
	/usr/bin/false r libmiscutil.a rfc1123.o rfc1738.o util.o ...
	make[1]: *** [libmiscutil.a] Error 255
	make[1]: Leaving directory `/tmp/squid-1.1.11/lib'
	make: *** [all] Error 1
</verb>
Note on the second line the <bf>/usr/bin/false</bf>.   This is supposed
to be a path to the <em/ar/ program.  If <em/configure/ cannot find <em/ar/
on your system, then it substitues <em/false/.

<P>
To fix this you either need to:
<itemize>
<item>
	Add <em>/usr/ccs/bin</em> to your PATH.  This is where the <em/ar/
	command should be.  You need to install SUNWbtool if <em/ar/
	is not there.  Otherwise,
<item>
	Install the <bf/binutils/ package from
	<url	url="ftp://ftp.gnu.org/gnu/binutils" name="the GNU FTP site">.
	This package includes programs such as <em/ar/, <em/as/, and <em/ld/.
</itemize>

<sect1>I have problems compiling Squid on Platform Foo.
<P>
Please check the
<url url="/platforms.html" name="page of platforms">
on which Squid is known to compile.  Your problem might be listed
there together with a solution.  If it isn't listed there, mail
us what you are trying, your Squid version, and the problems
you encounter.

<sect1>I see a lot warnings while compiling Squid.
<P>
Warnings are usually not a big concern, and can be common with software
designed to operate on multiple platforms.  If you feel like fixing
compile-time warnings, please do so and send us the patches.


<sect1>Building Squid on OS/2
<label id="building-os2">
<P>
by <url url="mailto:nazard@man-assoc.on.ca" name="Doug Nazar">

<P>
In order in compile squid, you need to have a reasonable facsimile of a
Unix system installed.  This includes <em/bash/, <em/make/, <em/sed/,
<em/emx/, various file utilities and a few more. I've setup a TVFS
drive that matches a Unix file system but this probably isn't strictly
necessary.

<P>
I made a few modifications to the pristine EMX 0.9d install.
<enum>
<item>
added defines for <em/strcasecmp()/ &amp; <em/strncasecmp()/ to <em/string.h/
<item>
changed all occurrences of time_t to signed long instead
of unsigned long
<item>
hacked ld.exe
	<enum>
	<item>
	to search for both xxxx.a and libxxxx.a
	<item>
	to produce the correct filename when using the
	-Zexe option
	</enum>
</enum>

<P>
You will need to run <em>scripts/convert.configure.to.os2</em> (in the
Squid source distribution) to modify
the configure script so that it can search for the various programs.

<P>
Next, you need to set a few environment variables (see EMX docs
for meaning):
<verb>
	export EMXOPT="-h256 -c"
	export LDFLAGS="-Zexe -Zbin -s"
</verb>

<P>
Now you are ready to configure squid:
<verb>
	./configure
</verb>
<P>
Compile everything:
<verb>
	make
</verb>
<P>
and finally, install:
<verb>
	make install
</verb>
<P>
This will by default, install into <em>/usr/local/squid</em>. If you wish
to install somewhere else, see the <em/--prefix/ option for configure.

<P>
Now, don't forget to set EMXOPT before running squid each time. I
recommend using the -Y and -N options.


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<sect>Installing and Running Squid

<sect1>How big of a system do I need to run Squid?

<P>
There are no hard-and-fast rules.  The most important resource
for Squid is physical memory.  Your processor does not need
to be ultra-fast.  Your disk system will be the major bottleneck,
so fast disks are important for high-volume caches.  Do not use
IDE disks if you can help it.

<P>
In late 1998, if you are buying a new machine for
a cache, I would recommend the following configuration:
<itemize>
<item>300 MHz Pentium II CPU
<item>512 MB RAM
<item>Five 9 GB UW-SCSI disks
</itemize>
Your system disk, and logfile disk can probably be IDE without losing
any cache performance.

<P>
Also, see <url url="http://wwwcache.ja.net/servers/squids.html"
name="Squid Sizing for Intel Platforms"> by Martin Hamilton This is a
very nice page summarizing system configurations people are using for
large Squid caches.

<sect1>How do I install Squid?

<P>
After <ref id="compiling" name="compiling Squid">, you can install it
with this simple command:
<verb>
	% make install
</verb>
If you have enabled the
<ref id="using-icmp" name="ICMP features">
then you will also want to type
<verb>
	% su
	# make install-pinger
</verb>

<P>
After installing, you will want to edit and customize
the <em/squid.conf/ file.  By default, this file is
located at <em>/usr/local/squid/etc/squid.conf</em>.

<P>
Also, a QUICKSTART guide has been included with the source
distribution.  Please see the directory where you
unpacked the source archive.

<sect1>What does the <em/squid.conf/ file do?
<P>
The <em/squid.conf/ file defines the configuration for
<em/squid/.  the configuration includes (but not limited to)
HTTP port number, the ICP request port number, incoming and outgoing
requests, information about firewall access, and various timeout
information.

<sect1>Do you have a <em/squid.conf/ example?
<P>
Yes, after you <tt/make install/, a sample <em/squid.conf/ file will
exist in the ``etc" directory under the Squid installation directory.

The sample <em/squid.conf/ file contains comments explaining each
option.
<P>

<sect1>How do I start Squid?

<P>
First you need to make your Squid configuration. The Squid configuration
can be found in /usr/local/squid/etc/squid.conf and by default includes
documentation on all directives.

<P>
In the Suqid distribution there is a small QUICKSTART guide indicating
which directives you need to look closer at and why. At a absolute minimum
you need to change the http_access configuration to allow access from
your clients.

<P>To verify your configuration file you can use the -k parse option
<verb>
	% /usr/local/squid/sbin/squid -k parse
</verb>
If this outputs any errors then these are syntax errors or other fatal
misconfigurations and needs to be corrected before you continue. If it is
silent and immediately gives back the command promt then your squid.conf
is syntactically correct and could be understood by Squid.

<P>
After you've finished editing the configuration file, you can
start Squid for the first time.  The procedure depends a little
bit on which version you are using.

<p>
First, you must create the swap directories.  Do this by
running Squid with the -z option:
<verb>
	% /usr/local/squid/sbin/squid -z
</verb>

<p>
NOTE: If you run Squid as root then you may need to first create
/usr/local/squid/var/logs and your cache_dir directories and assign ownership
of these to the cache_effective_user configured in your squid.conf.

<p>
Once the creation of the cache directories completes, you can start Squid
and try it out. Probably the best thing to do is run it from your terminal
and watch the debugging output.  Use this command:
<verb>
	% /usr/local/squid/sbin/squid -NCd1
</verb>
If everything is working okay, you will see the line:
<verb>
	Ready to serve requests.
</verb>
If you want to run squid in the background, as a daemon process,
just leave off all options:
<verb>
	% /usr/local/squid/sbin/squid
</verb>
<p>
NOTE: depending on which http_port you select you may need to start
squid as root (http_port <1024).

<P>
NOTE: In Squid-2.4 and earlier Squid was installed in bin by default, not sbin.

<sect1>How do I start Squid automatically when the system boots?

<P>
Squid-2 has a restart feature built in.  This greatly simplifies
starting Squid and means that you don't need to use <em/RunCache/
or <em/inittab/.  At the minimum, you only need to enter the
pathname to the Squid executable.  For example:
<verb>
	/usr/local/squid/sbin/squid
</verb>

<P>
Squid will automatically background itself and then spawn
a child process.  In your <em/syslog/ messages file, you
should see something like this:
<verb>
	Sep 23 23:55:58 kitty squid[14616]: Squid Parent: child process 14617 started
</verb>
That means that process ID 14563 is the parent process which monitors the child
process (pid 14617).  The child process is the one that does all of the
work.  The parent process just waits for the child process to exit.  If the 
child process exits unexpectedly, the parent will automatically start another
child process.  In that case, <em/syslog/ shows:
<verb>
	Sep 23 23:56:02 kitty squid[14616]: Squid Parent: child process 14617 exited with status 1
	Sep 23 23:56:05 kitty squid[14616]: Squid Parent: child process 14619 started
</verb>

<p>
If there is some problem, and Squid can not start, the parent process will give up
after a while.  Your <em/syslog/ will show:
<verb>
	Sep 23 23:56:12 kitty squid[14616]: Exiting due to repeated, frequent failures
</verb>
When this happens you should check your <em/syslog/ messages and
<em/cache.log/ file for error messages.

<p>
When  you look at a process (<em/ps/ command) listing,  you'll see two squid processes:
<verb>
	24353  ??  Ss     0:00.00 /usr/local/squid/bin/squid
	24354  ??  R      0:03.39 (squid) (squid)
</verb>
The first is the parent process, and the child process is the one called ``(squid)''.
Note that if you accidentally kill the parent process, the child process will not
notice.

<p>
If you want to run Squid from your termainal and prevent it from
backgrounding and spawning a child process, use the <em/-N/ command
line option.
<verb>
	/usr/local/squid/bin/squid -N
</verb>

<sect2>From inittab
<P>
On systems which have an <em>/etc/inittab</em> file (Digital Unix,
Solaris, IRIX, HP-UX, Linux), you can add a line like this:
<verb>
	sq:3:respawn:/usr/local/squid/sbin/squid.sh < /dev/null >> /tmp/squid.log 2>&1
</verb>
We recommend using a <em/squid.sh/ shell script, but you could instead call
Squid directly with the -N option and other options you may require.  A sameple <em/squid.sh/ script is shown below:
<verb>
	#!/bin/sh
	C=/usr/local/squid
	PATH=/usr/bin:$C/bin
	TZ=PST8PDT
	export PATH TZ
	
	# User to notify on restarts
	notify="root"

	# Squid command line options
	opts=""

	cd $C
	umask 022
	sleep 10
	while [ -f /var/run/nosquid ]; do
		sleep 1
	done
	/usr/bin/tail -20 $C/logs/cache.log \
		| Mail -s "Squid restart on `hostname` at `date`" $notify
	exec bin/squid -N $opts
</verb>

<sect2>From rc.local
<P>
On BSD-ish systems, you will need to start Squid from the ``rc'' files,
usually <em>/etc/rc.local</em>.  For example:
<verb>
	if [ -f /usr/local/squid/sbin/squid ]; then
		echo -n ' Squid'
		/usr/local/squid/sbin/squid
	fi
</verb>

<sect2>From init.d
<P>
Squid ships with a init.d type startup script in contrib/squid.rc which
works on most init.d type systems. Or you can write your own using any
normal init.d script found in your system as template and add the
start/stop fragments shown below.

<P>Start:
<verb>
        /usr/local/squid/sbin/squid
</verb>

<P>Stop:
<verb>
	/usr/local/squid/sbin/squid -k shutdown
	n=120
	while /usr/local/squid/sbin/squid -k check &amp;&amp; [ $n -gt 120 ]; do
	    sleep 1
	    echo -n .
	    n=`expr $n - 1`
	done
</verb>

<sect1>How do I tell if Squid is running?
<P>
You can use the <em/squidclient/ program:
<verb>
	% squidclient http://www.netscape.com/ &gt; test
</verb>

<P>
There are other command-line HTTP client programs available
as well.  Two that you may find useful are
<url	url="ftp://gnjilux.cc.fer.hr/pub/unix/util/wget/"
	name="wget">
and
<url	url="ftp://ftp.internatif.org/pub/unix/echoping/"
	name="echoping">.

<P>
Another way is to use Squid itself to see if it can signal a running
Squid process:
<verb>
	% squid -k check
</verb>
And then check the shell's exit status variable.

<P>
Also, check the log files, most importantly the <em/access.log/ and
<em/cache.log/ files.

<sect1><em/squid/ command line options
<P>
These are the command line options for <bf/Squid-2/:
<descrip>
<tag/-a/
	Specify an alternate port number for incoming HTTP requests.
	Useful for testing a configuration file on a non-standard port.
<tag/-d/
	Debugging level for ``stderr'' messages.  If you use this
	option, then debugging messages up to the specified level will
	also be written to stderr.
<tag/-f/
	Specify an alternate <em/squid.conf/ file instead of the
	pathname compiled into the executable.
<tag/-h/
	Prints the usage and help message.
<tag/-k reconfigure/
	Sends a <em/HUP/ signal, which causes Squid to re-read
	its configuration files.
<tag/-k rotate/
	Sends an <em/USR1/ signal, which causes Squid to
	rotate its log files.  Note, if <em/logfile_rotate/
	is set to zero, Squid still closes and re-opens
	all log files.
<tag/-k shutdown/
	Sends a <em/TERM/ signal, which causes Squid to
	wait briefly for current connections to finish and then
	exit.  The amount of time to wait is specified with
	<em/shutdown_lifetime/.
<tag/-k interrupt/
	Sends an <em/INT/ signal, which causes Squid to
	shutdown immediately, without waiting for
	current connections.
<tag/-k kill/
	Sends a <em/KILL/ signal, which causes the Squid
	process to exit immediately, without closing
	any connections or log files.  Use this only
	as a last resort.
<tag/-k debug/
	Sends an <em/USR2/ signal, which causes Squid
	to generate full debugging messages until the
	next <em/USR2/ signal is recieved.  Obviously
	very useful for debugging problems.
<tag/-k check/
	Sends a ``<em/ZERO/'' signal to the Squid process.
	This simply checks whether or not the process
	is actually running.
<tag/-s/
	Send debugging (level 0 only) message to syslog.
<tag/-u/
	Specify an alternate port number for ICP messages.
	Useful for testing a configuration file on a non-standard port.
<tag/-v/
	Prints the Squid version.
<tag/-z/
	Creates disk swap directories.  You must use this option when
	installing Squid for the first time, or when you add or
	modify the <em/cache_dir/ configuration.
<tag/-D/
	Do not make initial DNS tests.  Normally, Squid looks up
	some well-known DNS hostnames to ensure that your DNS
	name resolution service is working properly.
<tag/-F/
	If the <em/swap.state/ logs are clean, then the cache is
	rebuilt in the ``foreground'' before any requests are
	served.  This will decrease the time required to rebuild
	the cache, but HTTP requests will not be satisified during
	this time.
<tag/-N/
	Do not automatically become a background daemon process.
<tag/-R/
	Do not set the SO_REUSEADDR option on sockets.
<tag/-V/
	Enable virtual host support for the httpd-accelerator mode.
	This is identical to writing <em/httpd_accel_host virtual/
	in the config file.
<tag/-X/
	Enable full debugging while parsing the config file.
<tag/-Y/
	Return ICP_OP_MISS_NOFETCH instead of ICP_OP_MISS while
	the <em/swap.state/ file is being read.  If your cache has
	mostly child caches which use ICP, this will allow your
	cache to rebuild faster.
</descrip>

<sect1>How do I see how Squid works?
<P>
<itemize>
<item>
Check the <em/cache.log/ file in your logs directory.  It logs
interesting (and boring) things as a part of its normal operation.
<item>
Install and use the
<ref id="cachemgr-section" name="Cache Manager">.
</itemize>

<sect1>Can Squid benefit from SMP systems?

<P>Squid is a single process application and can not make use of SMP. 
If you want to make Squid benefit from a SMP system you will need to run 
multiple instances of Squid and find a way to distribute your users on the 
different Squid instances just as if you had multiple Squid boxes.

<P>Having two CPUs is indeed nice for running other CPU intensive 
tasks on the same server as the proxy, such as if you have a lot of logs 
and need to run various statistics collections during peak hours.

<P>The authentication and group helpers barely use any CPU and does 
not benefit from dual-CPU configuration.

<sect1>Is it okay to use separate drives and RAID on Squid?

<P>RAID1 is fine, and so are separate drives.

<P>RAID0 (striping) with Squid only gives you the drawback that if 
you loose one of the drives the whole stripe set is lost. There is no 
benefit in performance as Squid already distributes the load on the drives 
quite nicely. 

<P>Squid is the worst case application for RAID5, whether hardware or 
software, and will absolutely kill the performance of a RAID5. Once the 
cache has been filled Squid uses a lot of small random writes which the 
worst case workload for RAID5, effectively reducing write speed to only 
little more than that of one single drive.

<P>Generally seek time is what you want to optimize for Squid, or 
more precisely the total amount of seeks/s your system can sustain. 
Choosing the right RAID solution generally decreases the amount of seeks/s 
your system can sustain significantly.





<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<sect>Configuration issues

<sect1>How do I join a cache hierarchy?
<P>
To place your cache in a hierarchy, use the <tt/cache_peer/
directive in <em/squid.conf/ to specify the parent and sibling
nodes.

<P>
For example, the following <em/squid.conf/ file on
<tt/childcache.example.com/ configures its cache to retrieve
data from one parent cache and two sibling caches:

<verb>
        #  squid.conf - On the host: childcache.example.com
        #
        #  Format is: hostname  type  http_port  udp_port
        #
        cache_peer parentcache.example.com   parent  3128 3130
        cache_peer childcache2.example.com   sibling 3128 3130
        cache_peer childcache3.example.com   sibling 3128 3130
</verb>

The <tt/cache_peer_domain/ directive allows you to specify that
certain caches siblings or parents for certain domains:

<verb>
        #  squid.conf - On the host: sv.cache.nlanr.net
        #
        #  Format is: hostname  type  http_port  udp_port
        #

        cache_peer electraglide.geog.unsw.edu.au parent 3128 3130
        cache_peer cache1.nzgate.net.nz          parent 3128 3130
        cache_peer pb.cache.nlanr.net   parent 3128 3130
        cache_peer it.cache.nlanr.net   parent 3128 3130
        cache_peer sd.cache.nlanr.net   parent 3128 3130
        cache_peer uc.cache.nlanr.net   sibling 3128 3130
        cache_peer bo.cache.nlanr.net   sibling 3128 3130
        cache_peer_domain electraglide.geog.unsw.edu.au .au
        cache_peer_domain cache1.nzgate.net.nz   .au .aq .fj .nz
        cache_peer_domain pb.cache.nlanr.net     .uk .de .fr .no .se .it
        cache_peer_domain it.cache.nlanr.net     .uk .de .fr .no .se .it
        cache_peer_domain sd.cache.nlanr.net     .mx .za .mu .zm
</verb>

The configuration above indicates that the cache will use
<tt/pb.cache.nlanr.net/ and <tt/it.cache.nlanr.net/
for domains uk, de, fr, no, se and it, <tt/sd.cache.nlanr.net/
for domains mx, za, mu and zm, and <tt/cache1.nzgate.net.nz/
for domains au, aq, fj, and nz.

<sect1>How do I join NLANR's cache hierarchy?
<P>
We have a simple set of
<url	url="http://www.ircache.net/Cache/joining.html"
	name="guidelines for joining">
the NLANR cache hierarchy.

<sect1>Why should I want to join NLANR's cache hierarchy?
<P>
The NLANR hierarchy can provide you with an initial source for parent or
sibling caches.  Joining the NLANR global cache system will frequently
improve the performance of your caching service.

<sect1>How do I register my cache with NLANR's registration service?
<P>
Just enable these options in your <em/squid.conf/ and you'll be
registered:
<verb>
	cache_announce 24
	announce_to sd.cache.nlanr.net:3131
</verb>

<em/NOTE:/ announcing your cache <bf/is not/ the same thing as
joining the NLANR cache hierarchy.
You can join the NLANR cache hierarchy without registering, and
you can register without joining the NLANR cache hierarchy.
<P>

<sect1>How do I find other caches close to me and arrange parent/child/sibling relationships with them?
<P>
Visit the NLANR cache
<url	url="http://www.ircache.net/Cache/Tracker/"
	name="registration database">
to discover other caches near you.  Keep in mind that just because
a cache is registered in the database <bf/does not/ mean they
are willing to be your parent/sibling/child.  But it can't hurt to ask...
<P>

<sect1>My cache registration is not appearing in the Tracker database.

<P>
<itemize>
<item>
Your site will not be listed if your cache IP address does not have
a DNS PTR record. If we can't map the IP address back to a domain
name, it will be listed as ``Unknown.''
<item>
The registration messages are sent with UDP. We may not be receiving
your announcement message due to firewalls which block UDP, or
dropped packets due to congestion.
</itemize>

<sect1>What is the httpd-accelerator mode?
<P>
This entry has been moved to <ref id="what-is-httpd-accelerator" name="a different section">.

<sect1>How do I configure Squid to work behind a firewall?
<p>
<em>Note: The information here is current for version 2.2.</em>

<P>
If you are behind a firewall then you can't make direct connections
to the outside world, so you <bf/must/ use a
parent cache.  Squid doesn't use ICP queries for a request if it's
behind a firewall or if there is only one parent.

<P>
You can use the <tt/never_direct/ access list in
<em/squid.conf/ to specify which requests must be forwarded to
your parent cache outside the firewall, and the <tt/always_direct/ access list
to specify which requests must not be forwarded.  For example, if Squid
must connect directly to all servers that end with <em/mydomain.com/, but
must use the parent for all others, you would write:
<verb>
	acl INSIDE dstdomain .mydomain.com
	always_direct allow INSIDE
	never_direct allow all
</verb>

<p>
You could also specify internal servers by IP address
<verb>
	acl INSIDE_IP dst 1.2.3.0/24
	always_direct allow INSIDE_IP
	never_direct allow all
</verb>
Note, however that when you use IP addresses, Squid must
perform a DNS lookup to convert URL hostnames to an
address.  Your internal DNS servers may not be able to
lookup external domains.

<p>
If you use <em/never_direct/ and you have multiple parent caches,
then you probably will want to mark one of them as a default
choice in case Squid can't decide which one to use.  That is
done with the <em/default/ keyword on a <em/cache_peer/
line.  For example:
<verb>
	cache_peer xyz.mydomain.com parent 3128 0 default
</verb>

<sect1>How do I configure Squid forward all requests to another proxy?
<p>
<em>Note: The information here is current for version 2.2.</em>
<p>
First, you need to give Squid a parent cache.  Second, you need
to tell Squid it can not connect directly to origin servers.  This is done
with three configuration file lines:
<verb>
	cache_peer parentcache.foo.com parent 3128 0 no-query default
	acl all src 0.0.0.0/0.0.0.0
	never_direct allow all
</verb>
Note, with this configuration, if the parent cache fails or becomes
unreachable, then every request will result in an error message.

<p>
In case you want to be able to use direct connections when all the
parents go down you should use a different approach:
<verb>
	cache_peer parentcache.foo.com parent 3128 0 no-query
	prefer_direct off
</verb>
The default behaviour of Squid in the absence of positive ICP, HTCP, etc
replies is to connect to the origin server instead of using parents.
The <em>prefer_direct off</em> directive tells Squid to try parents first.

<sect1>I have <em/dnsserver/ processes that aren't being used, should I lower the number in <em/squid.conf/?
<P>
The <em/dnsserver/ processes are used by <em/squid/ because the <tt/gethostbyname(3)/ library routines used to
convert web sites names to their internet addresses
blocks until the function returns (i.e., the process that calls
it has to wait for a reply). Since there is only one <em/squid/
process, everyone who uses the cache would have to wait each
time the routine was called.  This is why the <em/dnsserver/ is
a separate process, so that these processes can block,
without causing blocking in <em/squid/.

<P>
It's very important that there are enough <em/dnsserver/
processes to cope with every access you will need, otherwise
<em/squid/ will stop occasionally.  A good rule of thumb is to
make sure you have at least the maximum number of dnsservers
<em/squid/ has <bf/ever/ needed on your system,
and probably add two to be on the safe side. In other words, if
you have only ever seen at most three <em/dnsserver/ processes
in use, make at least five.  Remember that a <em/dnsserver/ is
small and, if unused, will be swapped out.

<sect1>My <em/dnsserver/ average/median service time seems high, how can I reduce it?

<P>
First, find out if you have enough <em/dnsserver/ processes running by
looking at the Cachemanager <em/dns/ output.  Ideally, you should see
that the first <em/dnsserver/ handles a lot of requests, the second one
less than the first, etc.  The last <em/dnsserver/ should have serviced
relatively few requests.  If there is not an obvious decreasing trend, then
you need to increase the number of <em/dns_children/ in the configuration
file.  If the last <em/dnsserver/ has zero requests, then you definately
have enough.

<P>
Another factor which affects the <em/dnsserver/ service time is the
proximity of your DNS resolver.  Normally we do not recommend running
Squid and <em/named/ on the same host.  Instead you should try use a
DNS resolver (<em/named/) on a different host, but on the same LAN.
If your DNS traffic must pass through one or more routers, this could
be causing unnecessary delays.

<sect1>How can I easily change the default HTTP port?
<P>
Before you run the configure script, simply set the <em/CACHE_HTTP_PORT/
environment variable.
<verb>
	setenv CACHE_HTTP_PORT 8080
	./configure
	make
	make install
</verb>

<sect1>Is it possible to control how big each <em/cache_dir/ is?

<P>
With Squid-1.1 it is NOT possible.  Each <em/cache_dir/ is assumed
to be the same size.  The <em/cache_swap/ setting defines the size of
all <em/cache_dir/'s taken together.  If you have N <em/cache_dir/'s
then each one will hold <em/cache_swap/ &divide; N Megabytes.

<sect1>What <em/cache_dir/ size should I use?
<p>
Most people have a disk partition dedicated to the Squid cache.
You don't want to use the entire partition size.  You have to leave
some extra room.  Currently, Squid is not very tolerant of running
out of disk space. 
<p>
Lets say you have a 9GB disk.
Remember that disk manufacturers lie about the space available.
A so-called 9GB disk usually results in about 8.5GB of raw, usable space.
First, put a filesystem on it, and mount
it.  Then check the ``available space'' with your <em/df/ program.
Note that you lose some disk space to filesystem overheads, like superblocks,
inodes, and directory entries.  Also note that Unix normally keeps
10% free for itself.   So with a 9GB disk, you're probably down to
about 8GB after formatting.

<p>
Next, I suggest taking off another 10%
or so for Squid overheads, and a "safe buffer."  Squid normally puts
its <em/swap.state/ files in each cache directory.  These grow in size
until you rotate the logs, or restart squid.
Also note that Squid performs better when there is
more free space.  So if performance is important to you, then take off
even more space.  Typically, for a 9GB disk, I recommend a <em/cache_dir/
setting of 6000 to 7500 Megabytes:
<verb>
cache_dir ... 7000 16 256
</verb>

<p>
Its better to start out conservative.  After the cache becomes full,
look at the disk usage.  If you think there is plenty of unused space,
then increase the <em/cache_dir/ setting a little.

<p>
If you're getting ``disk full'' write errors, then you definately need
to decrease your cache size.

<sect1>I'm adding a new <em/cache_dir/.  Will I lose my cache?
<P>
With Squid-1.1, yes, you will lose your cache.  This is because
version 1.1 uses a simplistic algorithm to distribute files
between cache directories.

<P>
With Squid-2, you will not lose your existing cache.
You can add and delete <em/cache_dir/'s without affecting
any of the others.

<sect1>Squid and <em/http-gw/ from the TIS toolkit.

<P>
Several people on both the <em/fwtk-users/ and the
<em/squid-users/ mailing asked
about using Squid in combination with http-gw from the
<url	url="http://www.tis.com/"
	name="TIS toolkit">.
The most elegant way in my opinion is to run an internal Squid caching
proxyserver which handles client requests and let this server forward
it's requests to the http-gw running on the firewall. Cache hits won't
need to be handled by the firewall.

<P>
In this example Squid runs on the same server as the http-gw, Squid uses
8000 and http-gw uses 8080 (web).  The local domain is <em/home.nl/.

<sect2>Firewall configuration:

<P>
Either run http-gw as a daemon from the <em>/etc/rc.d/rc.local</em> (Linux
Slackware):
<verb>
	exec /usr/local/fwtk/http-gw -daemon 8080
</verb>
or run it from inetd like this:
<verb>
	web stream      tcp      nowait.100  root /usr/local/fwtk/http-gw http-gw
</verb>
I increased the watermark to 100 because a lot of people run into
problems with the default value.

<P>
Make sure you have at least the following line in
<em>/usr/local/etc/netperm-table</em>:
<verb>
	http-gw:        hosts 127.0.0.1
</verb>
You could add the IP-address of your own workstation to this rule and
make sure the http-gw by itself works, like:
<verb>
	http-gw:	        hosts 127.0.0.1 10.0.0.1
</verb>

<sect2>Squid configuration:

<P>
The following settings are important:

<verb>
	http_port       8000
	icp_port        0

	cache_peer      localhost.home.nl parent 8080 0 default
	acl HOME	dstdomain .home.nl
	alwayws_direct	allow HOME
	never_direct	allow all
</verb>
This tells Squid to use the parent for all domains other than <em/home.nl/.
Below, <em/access.log/ entries show what happens if you do a reload on the
Squid-homepage:

<verb>
872739961.631   1566 10.0.0.21 ERR_CLIENT_ABORT/304 83 GET http://www.squid-cache.org/ - DEFAULT_PARENT/localhost.home.nl -
872739962.976   1266 10.0.0.21 TCP_CLIENT_REFRESH/304 88 GET http://www.nlanr.net/Images/cache_now.gif - DEFAULT_PARENT/localhost.home.nl -
872739963.007   1299 10.0.0.21 ERR_CLIENT_ABORT/304 83 GET http://www.squid-cache.org/Icons/squidnow.gif - DEFAULT_PARENT/localhost.home.nl -
872739963.061   1354 10.0.0.21 TCP_CLIENT_REFRESH/304 83 GET http://www.squid-cache.org/Icons/Squidlogo2.gif - DEFAULT_PARENT/localhost.home.nl
</verb>

<P>
http-gw entries in syslog:

<verb>
Aug 28 02:46:00 memo http-gw[2052]: permit host=localhost/127.0.0.1 use of gateway (V2.0beta)
Aug 28 02:46:00 memo http-gw[2052]: log host=localhost/127.0.0.1 protocol=HTTP cmd=dir dest=www.squid-cache.org path=/
Aug 28 02:46:01 memo http-gw[2052]: exit host=localhost/127.0.0.1 cmds=1 in=0 out=0 user=unauth duration=1
Aug 28 02:46:01 memo http-gw[2053]: permit host=localhost/127.0.0.1 use of gateway (V2.0beta)
Aug 28 02:46:01 memo http-gw[2053]: log host=localhost/127.0.0.1 protocol=HTTP cmd=get dest=www.squid-cache.org path=/Icons/Squidlogo2.gif
Aug 28 02:46:01 memo http-gw[2054]: permit host=localhost/127.0.0.1 use of gateway (V2.0beta)
Aug 28 02:46:01 memo http-gw[2054]: log host=localhost/127.0.0.1 protocol=HTTP cmd=get dest=www.squid-cache.org path=/Icons/squidnow.gif
Aug 28 02:46:01 memo http-gw[2055]: permit host=localhost/127.0.0.1 use of gateway (V2.0beta)
Aug 28 02:46:01 memo http-gw[2055]: log host=localhost/127.0.0.1 protocol=HTTP cmd=get dest=www.nlanr.net path=/Images/cache_now.gif
Aug 28 02:46:02 memo http-gw[2055]: exit host=localhost/127.0.0.1 cmds=1 in=0 out=0 user=unauth duration=1
Aug 28 02:46:03 memo http-gw[2053]: exit host=localhost/127.0.0.1 cmds=1 in=0 out=0 user=unauth duration=2
Aug 28 02:46:04 memo http-gw[2054]: exit host=localhost/127.0.0.1 cmds=1 in=0 out=0 user=unauth duration=3
</verb>


<P>
To summarize:

<P>
Advantages:
<itemize>
<item>
http-gw allows you to selectively block ActiveX and Java, and it's
primary design goal is security.
<item>
The firewall doesn't need to run large applications like Squid.
<item>
The internal Squid-server still gives you the benefit of caching.
</itemize>

<P>
Disadvantages:
<itemize>
<item>
The internal Squid proxyserver can't (and shouldn't) work with other
parent or neighbor caches.
<item>
Initial requests are slower because these go through http-gw, http-gw
also does reverse lookups. Run a nameserver on the firewall or use an
internal nameserver.
</itemize>


<quote>
--<url	url="mailto:RvdOever@baan.nl" name="Rodney van den Oever">
</quote>


<sect1>What is ``HTTP_X_FORWARDED_FOR''?  Why does squid provide it to WWW servers, and how can I stop it?

<P>
When a proxy-cache is used, a server does not see the connection
coming from the originating client.  Many people like to implement
access controls based on the client address.
To accommodate these people, Squid adds its own request header
called "X-Forwarded-For" which looks like this:
<verb>
	X-Forwarded-For: 128.138.243.150, unknown, 192.52.106.30
</verb>
Entries are always IP addresses, or the word <em/unknown/ if the address
could not be determined or if it has been disabled with the
<em/forwarded_for/ configuration option.

<P>
We must note that access controls based on this header are extremely
weak and simple to fake.  Anyone may hand-enter a request with any IP
address whatsoever.  This is perhaps the reason why client IP addresses
have been omitted from the HTTP/1.1 specification.

<P>
Because of the weakness of this header support for access controls based
on X-Forwarder-For is not yet available in any officially released version of
squid.  However, unofficial patches are available from the <url
url="http://devel.squid-cache.org/follow_xff/index.html" name="follow_xff">
Squid development project and may be integrated into later versions of Squid
once a suitable trust model have been developed.

<sect1>Can Squid anonymize HTTP requests?
<p>
Yes it can, however the way of doing it has changed from earlier versions
of squid. As of squid-2.2 a more customisable method has been introduced.
Please follow the instructions for the version of squid that you are using.
As a default, no anonymizing is done.

<p>
If you choose to use the anonymizer you might wish to investigate the forwarded_for
option to prevent the client address being disclosed. Failure to turn off the
forwarded_for option will reduce the effectiveness of the anonymizer. Finally
if you filter the User-Agent header using the fake_user_agent option can
prevent some user problems as some sites require the User-Agent header.

<sect2>Squid 2.2
<p>
With the introduction of squid 2.2 the anonoymizer has become more customisable.
It now allows specification of exactly which headers will be allowed to pass.
This is further extended in Squid-2.5 to allow headers to be anonymized conditionally.

<P>
For details see the documentation of the http_header_access and header_replace
directives in squid.conf.default.

<P>
References:
<url url="http://www.iks-jena.de/mitarb/lutz/anon/web.en.html"
	name="Anonymous WWW">


<sect1>Can I make Squid go direct for some sites?
<p>
Sure, just use the <em/always_direct/ access list.
<p>
For example, if you want Squid to connect directly to <em/hotmail.com/ servers,
you can use these lines in  your config file:
<verb>
acl hotmail dstdomain .hotmail.com
always_direct allow hotmail
</verb>

<sect1>Can I make Squid proxy only, without caching anything?
<p>
Sure, there are few things you can do.
<p>
You can use the <em/no_cache/ access list to make Squid never cache any response:
<verb>
	acl all src 0/0
	no_cache deny all
</verb>
<p>
With Squid-2.4 and later you can use the ``null'' storage module to avoid
having a cache directory:
<verb>
	cache_dir null /tmp
</verb>

<p>
Note: a null cache_dir does not disable caching, but it does save you from
creating a cache structure if you have disabled caching with no_cache.

<p>
Note: the directory (e.g., <em>/tmp</em>) must exist so that squid
can chdir to it, unless you also use the <em/coredump_dir/ option.
<p>
To configure Squid for the ``null'' storage module, specify it
on the <em/configure/ command line:
<verb>
	./configure --enable-storeio=ufs,null ...
</verb>

<sect1>Can I prevent users from downloading large files?
<p>
You can set the global <em/reply_body_max_size/ parameter.  This option
controls the largest HTTP message body that will be sent to a cache
client for one request.
<p>
If the HTTP response coming from the server has a <tt/Content-length/
header, then Squid compares the content-length value to the
<em/reply_body_max_size/ value.  If the content-length is larger,
the server connection is closed and the user receives an error
message from Squid.
<p>
Some responses don't have <tt/Content-length/
headers.  In this case, Squid counts how many bytes are written
to the client.  Once the limit is reached, the client's connection
is simply closed.
<p>
Note that ``creative'' user-agents will still be able to download
really large files through the cache using HTTP/1.1 range requests.

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<sect>Communication between browsers and Squid

<P>
Most web browsers available today support proxying and are easily configured
to use a Squid server as a proxy.  Some browsers support advanced features
such as lists of domains or URL patterns that shouldn't be fetched through
the proxy, or JavaScript automatic proxy configuration.

<sect1>Netscape manual configuration
<P>
Select <bf/Network Preferences/ from the
<bf/Options/ menu.  On the <bf/Proxies/
page, click the radio button next to <bf/Manual Proxy
Configuration/ and then click on the <bf/View/
button.  For each protocol that your Squid server supports (by default,
HTTP, FTP, and gopher) enter the Squid server's hostname or IP address
and put the HTTP port number for the Squid server (by default, 3128) in
the <bf/Port/ column.  For any protocols that your Squid
does not support, leave the fields blank.
<P>
Here is a
<url	url="/Doc/FAQ/navigator.jpg"
	name="screen shot"> of the Netscape Navigator manual proxy
configuration screen.
<P>

<sect1>Netscape automatic configuration
<label id="netscape-pac">
<P>
Netscape Navigator's proxy configuration can be automated with
JavaScript (for Navigator versions 2.0 or higher).  Select
<bf/Network Preferences/ from the <bf/Options/
menu.  On the <bf/Proxies/ page, click the radio button
next to <bf/Automatic Proxy Configuration/ and then
fill in the URL for your JavaScript proxy configuration file in the
text box.  The box is too small, but the text will scroll to the
right as you go.
<P>
Here is a
<url	url="/Doc/FAQ/navigator-auto.jpg"
	name="screen shot">
of the Netscape Navigator automatic proxy configuration screen.

You may also wish to consult Netscape's documentation for the Navigator
<url
url="http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html"
name="JavaScript proxy configuration">

<P>
Here is a sample auto configuration JavaScript from Oskar Pearson:
<code>
//We (www.is.co.za) run a central cache for our customers that they
//access through a firewall - thus if they want to connect to their intranet
//system (or anything in their domain at all) they have to connect
//directly - hence all the "fiddling" to see if they are trying to connect
//to their local domain.

//Replace each occurrence of company.com with your domain name
//and if you have some kind of intranet system, make sure
//that you put it's name in place of "internal" below.

//We also assume that your cache is called "cache.company.com", and
//that it runs on port 8080. Change it down at the bottom.

//(C) Oskar Pearson and the Internet Solution (http://www.is.co.za)

    function FindProxyForURL(url, host)
        {
            //If they have only specified a hostname, go directly.
            if (isPlainHostName(host))
                    return "DIRECT";

            //These connect directly if the machine they are trying to
            //connect to starts with "intranet" - ie http://intranet
            //Connect  directly if it is intranet.*
            //If you have another machine that you want them to
            //access directly, replace "internal*" with that
            //machine's name
            if (shExpMatch( host, "intranet*")||
                            shExpMatch(host, "internal*"))
                return "DIRECT";

            //Connect directly to our domains (NB for Important News)
            if (dnsDomainIs( host,"company.com")||
            //If you have another domain that you wish to connect to
            //directly, put it in here
                            dnsDomainIs(host,"sistercompany.com"))
                return "DIRECT";

            //So the error message "no such host" will appear through the
            //normal Netscape box - less support queries :)
            if (!isResolvable(host))
                    return "DIRECT";

            //We only cache http, ftp and gopher
            if (url.substring(0, 5) == "http:" ||
                            url.substring(0, 4) == "ftp:"||
                            url.substring(0, 7) == "gopher:")

            //Change the ":8080" to the port that your cache
            //runs on, and "cache.company.com" to the machine that
            //you run the cache on
                    return "PROXY cache.company.com:8080; DIRECT";

            //We don't cache WAIS
            if (url.substring(0, 5) == "wais:")
                    return "DIRECT";

            else
                    return "DIRECT";
        }
</code>

<sect1>Lynx and Mosaic configuration
<P>
For Mosaic and Lynx, you can set environment variables
before starting the application.  For example (assuming csh or tcsh):
<P>
<verb>
	% setenv http_proxy http://mycache.example.com:3128/
	% setenv gopher_proxy http://mycache.example.com:3128/
	% setenv ftp_proxy http://mycache.example.com:3128/
</verb>
<P>
For Lynx you can also edit the <em/lynx.cfg/ file to configure
proxy usage.  This has the added benefit of causing all Lynx users on
a system to access the proxy without making environment variable changes
for each user.  For example:
<verb>
        http_proxy:http://mycache.example.com:3128/
        ftp_proxy:http://mycache.example.com:3128/
        gopher_proxy:http://mycache.example.com:3128/
</verb>

<sect1>Redundant Proxy Auto-Configuration

<P>
There's one nasty side-effect to using auto-proxy scripts: if you start
the web browser it will try and load the auto-proxy-script.

<P>
If your script isn't available either because the web server hosting the
script is down or your workstation can't reach the web server (e.g.
because you're working off-line with your notebook and just want to
read a previously saved HTML-file) you'll get different errors depending
on the browser you use.

<P>
The Netscape browser will just return an error after a timeout (after
that it tries to find the site 'www.proxy.com' if the script you use is
called 'proxy.pac').

<P>
The Microsoft Internet Explorer on the other hand won't even start, no
window displays, only after about 1 minute it'll display a window asking
you to go on with/without proxy configuration.

<P>
The point is that your workstations always need to locate the
proxy-script. I created some extra redundancy by hosting the script on
two web servers (actually Apache web servers on the proxy servers
themselves) and adding the following records to my primary nameserver:
<verb>
	proxy   CNAME           proxy1
        	CNAME           proxy2
</verb>
The clients just refer to 'http://proxy/proxy.pac'.  This script looks like this:

<verb>
function FindProxyForURL(url,host)
{
        // Hostname without domainname or host within our own domain?
	// Try them directly:
        // http://www.domain.com actually lives before the firewall, so
	// make an exception:
        if ((isPlainHostName(host)||dnsDomainIs( host,".domain.com")) &&
                !localHostOrDomainIs(host, "www.domain.com"))
                return "DIRECT";

        // First try proxy1 then proxy2. One server mostly caches '.com'
	// to make sure both servers are not
        // caching the same data in the normal situation. The other
	// server caches the other domains normally.
        // If one of 'm is down the client will try the other server.
        else if (shExpMatch(host, "*.com"))
		return "PROXY proxy1.domain.com:8080; PROXY proxy2.domain.com:8081; DIRECT";
        return "PROXY proxy2.domain.com:8081; PROXY proxy1.domain.com:8080; DIRECT";
}
</verb>

<P>
I made sure every client domain has the appropriate 'proxy' entry.
The clients are automatically configured with two nameservers using
DHCP.

<quote>
--<url	url="mailto:RvdOever@baan.nl"
	name="Rodney van den Oever">
</quote>

<sect1>Proxy Auto-Configuration with URL Hashing
<p>
The
<url url="http://naragw.sharp.co.jp/sps/" name="Sharp Super Proxy Script page">
contains a lot of good information about hash-based proxy auto-configuration
scripts.  With these you can distribute the load between a number
of caching proxies.

<sect1>Microsoft Internet Explorer configuration
<P>
Select <bf/Options/ from the <bf/View/
menu.  Click on the <bf/Connection/ tab.  Tick the
<bf/Connect through Proxy Server/ option and hit the
<bf/Proxy Settings/ button.  For each protocol that
your Squid server supports (by default, HTTP, FTP, and gopher)
enter the Squid server's hostname or IP address and put the HTTP
port number for the Squid server (by default, 3128) in the
<bf/Port/ column.  For any protocols that your Squid
does not support, leave the fields blank.
<P>
Here is a
<url	url="/Doc/FAQ/msie.jpg"
	name="screen shot"> of the Internet Explorer proxy
configuration screen.
<P>
Microsoft is also starting to support Netscape-style JavaScript
automated proxy configuration.  As of now, only MSIE version 3.0a
for Windows 3.1 and Windows NT 3.51 supports this feature (i.e.,
as of version 3.01 build 1225 for Windows 95 and NT 4.0, the feature
was not included).
<P>
If you have a version of MSIE that does have this feature, elect
<bf/Options/ from the <bf/View/ menu.
Click on the <bf/Advanced/ tab.  In the lower left-hand
corner, click on the <bf/Automatic Configuration/
button.  Fill in the URL for your JavaScript file in the dialog
box it presents you.  Then exit MSIE and restart it for the changes
to take effect.  MSIE will reload the JavaScript file every time
it starts.

<sect1>Netmanage Internet Chameleon WebSurfer configuration
<P>
Netmanage WebSurfer supports manual proxy configuration and exclusion
lists for hosts or domains that should not be fetched via proxy
(this information is current as of WebSurfer 5.0).  Select
<bf/Preferences/ from the <bf/Settings/
menu.  Click on the <bf/Proxies/ tab.  Select the
<bf/Use Proxy/ options for HTTP, FTP, and gopher.  For
each protocol that enter the Squid server's hostname or IP address
and put the HTTP port number for the Squid server (by default,
3128) in the <bf/Port/ boxes.  For any protocols that
your Squid does not support, leave the fields blank.
<P>
Take a look at this
<url	url="/Doc/FAQ/netmanage.jpg"
	name="screen shot">
if the instructions confused you.
<P>
On the same configuration window, you'll find a button to bring up
the exclusion list dialog box, which will let you enter some hosts
or domains that you don't want fetched via proxy.  It should be
self-explanatory, but you might look at this
<url	url="/Doc/FAQ/netmanage-exclusion.jpg"
	name="screen shot">
just for fun anyway.

<sect1>Opera 2.12 proxy configuration

<P>
Select <em/Proxy Servers.../ from the <em/Preferences/ menu.  Check each
protocol that your Squid server supports (by default, HTTP, FTP, and
Gopher) and enter the Squid server's address as hostname:port (e.g.
mycache.example.com:3128 or 123.45.67.89:3128).  Click on <em/Okay/ to accept the
setup.

<P>
Notes:
<itemize>
<item>
Opera 2.12 doesn't support gopher on its own, but requires a proxy; therefore
Squid's gopher proxying can extend the utility of your Opera immensely.
<item>
Unfortunately, Opera 2.12 chokes on some HTTP requests, for example
<url	url="http://spam.abuse.net/spam/"
	name="abuse.net">.
At the moment I think it has something to do with cookies.  If you have
trouble with a site, try disabling the HTTP proxying by unchecking
that protocol in the <em/Preferences/|<em/Proxy Servers.../ dialogue.  Opera will
remember the address, so reenabling is easy.
</itemize>

<quote>
--<url url="mailto:hclsmith@tallships.istar.ca" name="Hume Smith">
</quote>

<sect1>How do I tell Squid to use a specific username for FTP urls?

<P>
Insert your username in the host part of the URL, for example:
<verb>
	ftp://joecool@ftp.foo.org/
</verb>
Squid should then prompt you for your account password.  Alternatively,
you can specify both your username and password in the URL itself:
<verb>
	ftp://joecool:secret@ftp.foo.org/
</verb>
However, we certainly do not recommend this, as it could be very
easy for someone to see or grab your password.

<sect1>Configuring Browsers for WPAD
<P>
by <url url="mailto:mark@rts.com.au" name="Mark Reynolds">
<P>
You may like to start by reading the
<url url="http://www.web-cache.com/Writings/Internet-Drafts/draft-ietf-wrec-wpad-01.txt" name="Expired Internet-Draft">
that describes WPAD.

<P>
After reading the 8 steps below, if you don't understand any of the
terms or methods mentioned, you probably shouldn't be doing this.
Implementing wpad requires you to <bf/fully/ understand:
<enum>
  <item> web server installations and modifications.
  <item>squid proxy server (or others) installation etc.
  <item>Domain Name System maintenance etc.
</enum>
Please don't bombard the squid list with web server or dns questions. See
your system administrator, or do some more research on those topics.

<P>
This is not a recommendation for any product or version. As far as I
know IE5 is the only browser out now implementing wpad. I think wpad
is an excellent feature that will return several hours of life per month.
Hopefully, all browser clients will implement it as well. But it will take
years for all the older browsers to fade away though.

<P>
I have only focused on the domain name method, to the exclusion of the
DHCP method. I think the dns method might be easier for most people.
I don't currently, and may never, fully understand wpad and IE5, but this
method worked for me. It <bf/may/ work for you.

<P>
But if you'd rather just have a go ...
<enum>
<item>
   Create a standard <ref id="netscape-pac" name="netscape auto
   proxy config file">.  The sample provided there is more than
   adequate to get you going.  No doubt all the other load balancing
   and backup scripts will be fine also.

<item>
   Store the resultant file in the document root directory of a
   handy web server as <em/wpad.dat/ (Not <em/proxy.pac/ as you
   may have previously done.)

   <p>
   <url url="mailto:ira at racoon.riga.lv" name="Andrei Ivanov">
   notes that you should be able to use an HTTP redirect if you
   want to store the wpad.dat file somewhere else.  You can probably
   even redirect <em/wpad.dat/ to <em/proxy.pac/:
<verb>
Redirect /wpad.dat http://racoon.riga.lv/proxy.pac
</verb>

<item>
   If you do nothing more, a url like
   <tt>http://www.your.domain.name/wpad.dat</tt> should bring up
   the script text in your browser window.

<item>
   Insert the following entry into your web server <em/mime.types/ file.
   Maybe in addition to your pac file type, if you've done this before.
<verb>
	application/x-ns-proxy-autoconfig       dat
</verb>
   And then restart your web server, for new mime type to work.

<item>
   Assuming Internet Explorer 5, under <em/Tools/, <em/Internet
   Options/, <em/Connections/, <em/Settings/ <bf/or/ <em/Lan
   Settings/, set <bf/ONLY/ <em/Use Automatic Configuration Script/
   to be the URL for where your new <em/wpad.dat/ file can be found.
   i.e.  <tt>http://www.your.domain.name/wpad.dat</tt> Test that
   that all works as per your script and network.  There's no point
   continuing until this works ...

<item>
   Create/install/implement a DNS record so that
   <tt>wpad.your.domain.name</tt> resolves to the host above where
   you have a functioning auto config script running. You should
   now be able to use <tt>http://wpad.your.domain.name/wpad.dat</tt>
   as the Auto Config Script location in step 5 above.

<item>
   And finally, go back to the setup screen detailed in 5 above,
   and choose nothing but the <em/Automatically Detect Settings/
   option, turning everything else off. Best to restart IE5, as
   you normally do with any Microsoft product... And it should all
   work. Did for me anyway.

<item>
   One final question might be 'Which domain name does the client
   (IE5) use for the wpad... lookup?' It uses the hostname from
   the control panel setting.  It starts the search by adding the
   hostname "WPAD" to current fully-qualified domain name.  For
   instance, a client in a.b.Microsoft.com would search for a WPAD
   server at wpad.a.b.microsoft.com. If it could not locate one,
   it would remove the bottom-most domain and try again; for
   instance, it would try wpad.b.microsoft.com next. IE 5 would
   stop searching when it found a WPAD server or reached the
   third-level domain, wpad.microsoft.com.


</enum>

<P>
Anybody using these steps to install and test, please feel free to make
notes, corrections or additions for improvements, and post back to the
squid list...

<P>
There are probably many more tricks and tips which hopefully will be
detailed here in the future. Things like <em/wpad.dat/ files being served
from the proxy server themselves, maybe with a round robin dns setup
for the WPAD host.

<sect1>Configuring Browsers for WPAD with DHCP
<P>
You can also use DHCP to configure browsers for WPAD.
This technique allows you to set any URL as the PAC
URL.  For ISC DHCPD, enter a line like this in your
<em/dhcpd.conf/ file:
<verb>
	option wpad code 252 = text;
	option wpad "http://www.example.com/proxy.pac";
</verb>
<p>
Replace the hostname with the name or address of your
own server.
<p>
Ilja Pavkovic notes that the DHCP mode does not work reliably with
every version of Internet Explorer. The DNS name method to find
wpad.dat is more reliable.
<p>
Another user adds that IE 6.01 seems to strip the last character
from the URL.  By adding a trailing newline, he is able to make
it work with both IE 5.0 and 6.0:<
<verb>
	option wpad "http://www.example.com/proxy.pac\n";
</verb>


<sect1>IE 5.0x crops trailing slashes from FTP URL's
<p>
by <url url="mailto:reuben at reub dot net" name="Reuben Farrelly">
<p>
There was a bug in the 5.0x releases of Internet Explorer in which IE 
cropped any trailing slash off an FTP URL.  The URL showed up correctly in 
the browser's ``Address:'' field, however squid logs show that the trailing 
slash was being taken off.
<p>
An example of where this impacted squid if you had a setup where squid 
would go direct for FTP directory listings but forward a request to a 
parent for FTP file transfers.  This was useful if your upstream proxy was 
an older version of Squid or another vendors software which displayed 
directory listings with broken icons and you wanted your own local version 
of squid to generate proper FTP directory listings instead.
The workaround for this is to add a double slash to any directory listing 
in which the slash was important, or else upgrade to IE 5.5.  (Or use Netscape)

<sect1>IE 6.0 SP1 fails when using authentication

<P>
When using authentication with Internet Explorer 6 SP1, you may 
encounter issues when you first launch Internet Explorer.
The problem will show itself when you first authenticate, you will
receive a "Page Cannot Be Displayed" error. However, if you click
refresh, the page will be correctly displayed. 

<P>
This only happens immediately after you authenticate.

<P>
This is not a Squid error or bug.   Microsoft broke the Basic
Authentication when they put out IE6 SP1.

<P>
There is a knowledgebase article 
(<URL url="http://support.microsoft.com/default.aspx?id=kb;en-us;331906" NAME="KB 331906">)
regarding this issue, which contains a link to a downloadable 
"hot fix." They do warn that this code is not "regression tested"
but so far there have not been any reports of this breaking anything
else. The problematic file is wininet.dll. Please note that this
hotfix is included in the latest security update.

<p>
Lloyd Parkes notes that the article references another article,
<url url="http://support.microsoft.com/default.aspx?scid=kb;EN-US;312176" name="KB 312176">.
He says that you must <bf/not/ have the registry entry that KB
312176 encourages users to add to their registry.

<p>
According to Joao Coutinho, this simple solution also corrects the problem:
<itemize>
<item>Go to Tools/Internet
<item>Go to Options/Advanced
<item>UNSELECT "Show friendly HTTP error messages" under Browsing.
</itemize>

<P>
Another possible workaround to these problems is to make the
ERR_CACHE_ACCESS_DENIED larger than 1460 bytes. This should trigger
IE to handle the authentication in a slightly different manner.

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<sect>Squid Log Files

<P>
The logs are a valuable source of information about Squid workloads and
performance. The logs record not only access information, but also system
configuration errors and resource consumption (eg, memory, disk
space). There are several log file maintained by Squid. Some have to be
explicitely activated during compile time, others can safely be deactivated
during run-time.

<P>
There are a few basic points common to all log files. The time stamps
logged into the log files are usually UTC seconds unless stated otherwise.
The initial time stamp usually contains a millisecond extension.

<sect1><em/squid.out/

<P>
If you run your Squid from the <em/RunCache/ script, a file
<em/squid.out/ contains the Squid startup times, and also all fatal
errors, e.g. as produced by an <em/assert()/ failure. If you are not
using <em/RunCache/, you will not see such a file.

<sect1><em/cache.log/

<P>
The <em/cache.log/ file contains the debug and error messages that Squid
generates. If you start your Squid using the default <em/RunCache/ script,
or start it with the <em/-s/ command line option, a copy of certain
messages will go into your syslog facilities. It is a matter of personal
preferences to use a separate file for the squid log data.

<P>
From the area of automatic log file analysis, the <em/cache.log/ file does
not have much to offer. You will usually look into this file for automated
error reports, when programming Squid, testing new features, or searching
for reasons of a perceived misbehaviour, etc.


<sect1><em/useragent.log/

<P>
The user agent log file is only maintained, if 

<enum>
<item>you configured the compile time <em/--enable-useragent-log/
  option, and
<item>you pointed the <em/useragent_log/ configuration option to a
  file.
</enum>

<P>
From the user agent log file you are able to find out about distributation
of browsers of your clients. Using this option in conjunction with a loaded
production squid might not be the best of all ideas.

<sect1><em/store.log/

<P>
The <em/store.log/ file covers the objects currently kept on disk or
removed ones. As a kind of transaction log it is ususally used for
debugging purposes. A definitive statement, whether an object resides on
your disks is only possible after analysing the <em/complete/ log file.
The release (deletion) of an object may be logged at a later time than the
swap out (save to disk).

<P>
The <em/store.log/ file may be of interest to log file analysis which
looks into the objects on your disks and the time they spend there, or how
many times a hot object was accessed. The latter may be covered by another
log file, too. With knowledge of the <em/cache_dir/ configuration option,
this log file allows for a URL to filename mapping without recursing your
cache disks. However, the Squid developers recommend to treat
<em/store.log/ primarily as a debug file, and so should you, unless you
know what you are doing.

<P>
The print format for a store log entry (one line) consists of eleven
space-separated columns, compare with the <em/storeLog()/ function in file
<em>src/store_log.c</em>:

<verb>
    "%9d.%03d %-7s %08X %4d %9d %9d %9d %s %d/%d %s %s\n"
</verb>

<descrip>
<tag/time/
<P>
The timestamp when the line was logged in UTC with a millisecond fraction.

<tag/action/
<P>
The action the object was sumitted to, compare with <em>src/store_log.c</em>:

<itemize>
<item><bf/CREATE/ Seems to be unused.
<item><bf/RELEASE/ The object was removed from the cache (see also
 <ref id="log-fileno" name="file number">).  
<item><bf/SWAPOUT/ The object was saved to disk.
<item><bf/SWAPIN/ The object existed on disk and was read into memory.
</itemize>

<tag/file number/<label id="log-fileno">
<P>
The file number for the object storage file. Please note that the path to
this file is calculated according to your <em/cache_dir/ configuration.

<P>
A file number of <em/FFFFFFFF/ denominates "memory only" objects. Any
action code for such a file number refers to an object which existed only
in memory, not on disk.  For instance, if a <em/RELEASE/ code was logged
with file number <em/FFFFFFFF/, the object existed only in memory, and was
released from memory.

<tag/status/
<P>
The HTTP reply status code.

<tag/datehdr/<label id="log-Date">
<P>
The value of the HTTP "Date: " reply header.

<tag/lastmod<label id="log-LM">
<P>
The value of the HTTP "Last-Modified: " reply header.

<tag/expires/<label id="log-Expires">
<P>
The value of the HTTP "Expires: " reply header.

<tag/type/
<P>
The HTTP "Content-Type" major value, or "unknown" if it cannot be
determined.

<tag/sizes/
<P>
This column consists of two slash separated fields:

<enum>
<item>The advertised content length from the HTTP "Content-Length: " reply
  header.
<item>The size actually read.
</enum>

<P>
If the advertised (or expected) length is missing, it will be set to
zero. If the advertised length is not zero, but not equal to the real
length, the object will be realeased from the cache.

<tag/method/
<P>
The request method for the object, e.g. <em/GET/.

<tag/key/<label id="log-key">
<P>
The key to the object, usually the URL.
</descrip>

<P>
The timestamp format for the columns <ref id="log-Date" name="Date"> to
<ref id="log-Expires" name="Expires"> are all expressed in UTC seconds. The
actual values are parsed from the HTTP reply headers. An unparsable header
is represented by a value of -1, and a missing header is represented by a
value of -2.

<P>
The column <ref id="log-key" name="key"> usually contains just the URL of
the object. Some objects though will never become public. Thus the key is
said to include a unique integer number and the request method in addition
to the URL.

<sect1><em/hierarchy.log/
<P>
This logfile exists for Squid-1.0 only.  The format is
<verb>
	[date] URL peerstatus peerhost
</verb>

<sect1><em/access.log/

<P>
Most log file analysis program are based on the entries in
<em/access.log/. Currently, there are two file formats possible for the log
file, depending on your configuration for the <em/emulate_httpd_log/
option. By default, Squid will log in its native log file format. If the
above option is enabled, Squid will log in the common log file format as
defined by the CERN web daemon.

<P>
The common log file format contains other information than the native log
file, and less. The native format contains more information for the admin
interested in cache evaluation.

<sect2><em/The common log file format/

<P>
The
<url	url="http://www.w3.org/Daemon/User/Config/Logging.html&num;common-logfile-format"
	name="Common Logfile Format">
is used by numerous HTTP servers. This format consists of the following
seven fields:
<verb>
	remotehost rfc931 authuser [date] "method URL" status bytes
</verb>
<P>
It is parsable by a variety of tools. The common format contains different
information than the native log file format. The HTTP version is logged,
which is not logged in native log file format.


<sect2><em/The native log file format/

<P>
The native format is different for different major versions of Squid.  For
Squid-1.0 it is:
<verb>
	time elapsed remotehost code/status/peerstatus bytes method URL
</verb>

<P>
For Squid-1.1, the information from the <em/hierarchy.log/ was moved
into <em/access.log/.  The format is:
<verb>
	time elapsed remotehost code/status bytes method URL rfc931 peerstatus/peerhost type
</verb>

<P>
For Squid-2 the columns stay the same, though the content within may change
a little.

<P>
The native log file format logs more and different information than the
common log file format: the request duration, some timeout information,
the next upstream server address, and the content type.

There exist tools, which convert one file format into the other. Please
mind that even though the log formats share most information, both formats
contain information which is not part of the other format, and thus this
part of the information is lost when converting. Especially converting back
and forth is not possible without loss.

<em/squid2common.pl/ is a conversion utility, which converts any of the
squid log file formats into the old CERN proxy style output. There exist
tools to analyse, evaluate and graph results from that format.


<sect2><em/access.log native format in detail/

<P>
It is recommended though to use Squid's native log format due to its
greater amount of information made available for later analysis. The print
format line for native <em/access.log/ entries looks like this:

<verb>
    "%9d.%03d %6d %s %s/%03d %d %s %s %s %s%s/%s %s"
</verb>

<P>
Therefore, an <em/access.log/ entry usually consists of (at least) 10
columns separated by one ore more spaces:

<descrip>
<tag/time/
<P>
A Unix timestamp as UTC seconds with a millisecond resolution. You
can convert Unix timestamps into something more human readable using
this short perl script:
<verb>
	#! /usr/bin/perl -p
	s/^\d+\.\d+/localtime $&/e;
</verb>

<tag/duration/
<P>
The elapsed time considers how many milliseconds the transaction
busied the cache. It differs in interpretation between TCP and UDP:
<P>
<itemize>
<item>For HTTP/1.0, this is basically the time between <em/accept()/
 and <em/close()/.
<item>For persistent connections, this ought to be the time between
 scheduling the reply and finishing sending it.
<item>For ICP, this is the time between scheduling a reply and actually
 sending it.
</itemize>
<P>
Please note that the entries are logged <em/after/ the reply finished
being sent, <em/not/ during the lifetime of the transaction.

<tag/client address/
<P>
The IP address of the requesting instance, the client IP address. The
<em/client_netmask/ configuration option can distort the clients for data
protection reasons, but it makes analysis more difficult. Often it is
better to use one of the log file anonymizers.
<P>
Also, the <em/log_fqdn/ configuration option may log the fully qualified
domain name of the client instead of the dotted quad. The use of that
option is discouraged due to its performance impact.

<tag/result codes/<label id="log-resultcode">
<P>
This column is made up of two entries separated by a slash. This column
encodes the transaction result:

<enum>
<item>The cache result of the request contains information on the kind of
    request, how it was satisfied, or in what way it failed. Please refer
    to section <ref id="cache-result-codes" name="Squid result codes">
    for valid symbolic result codes.
    
    <P>
    Several codes from older versions are no longer available, were
    renamed, or split. Especially the <em/ERR_/ codes do not seem to
    appear in the log file any more. Also refer to section
    <ref id="cache-result-codes" name="Squid result codes"> for details
    on the codes no longer available in Squid-2.
    
    <P>
    The NOVM versions and Squid-2 also rely on the Unix buffer cache, thus
    you will see less <em/TCP_MEM_HIT/s than with a Squid-1.
    Basically, the NOVM feature relies on <em/read()/ to obtain an
    object, but due to the kernel buffer cache, no disk activity is needed.
    Only small objects (below 8KByte) are kept in Squid's part of main
    memory.

<item>The status part contains the HTTP result codes with some Squid specific
    extensions. Squid uses a subset of the RFC defined error codes for
    HTTP. Refer to section <ref id="http-status-codes" name="status codes">
    for details of the status codes recognized by a Squid-2.
</enum>

<tag/bytes/
<P>
The size is the amount of data delivered to the client. Mind that this does
not constitute the net object size, as headers are also counted. Also,
failed requests may deliver an error page, the size of which is also logged
here.

<tag/request method/
<P>
The request method to obtain an object. Please refer to section
<ref id="request-methods"> for available methods.
If you turned off <em/log_icp_queries/ in your configuration, you
will not see (and thus unable to analyse) ICP exchanges. The <em/PURGE/
method is only available, if you have an ACL for ``method purge'' enabled
in your configuration file.

<tag/URL/
<P>
This column contains the URL requested. Please note that the log file
may contain whitespaces for the URI. The default configuration for
<em/uri_whitespace/ denies whitespaces, though.

<tag/rfc931/
<P>
The eigth column may contain the ident lookups for the requesting
client. Since ident lookups have performance impact, the default
configuration turns <em/ident_loookups/ off. If turned off, or no ident
information is available, a ``-'' will be logged.

<tag/hierarchy code/
<P>
The hierarchy information consists of three items:
<P>
<enum>
<item>Any hierarchy tag may be prefixed with <em/TIMEOUT_/, if the
    timeout occurs waiting for all ICP replies to return from the
    neighbours. The timeout is either dynamic, if the
    <em/icp_query_timeout/ was not set, or the time configured there
    has run up.
<item>A code that explains how the request was handled, e.g. by
    forwarding it to a peer, or going straight to the source. Refer to
    section <ref id="hier-codes"> for details on hierarchy codes and
    removed hierarchy codes.
<item>The IP address or hostname where the request (if a miss) was forwarded.
    For requests sent to origin servers, this is the origin server's IP address.
    For requests sent to a neighbor cache, this is the neighbor's hostname.
    NOTE: older versions of Squid would put the origin server hostname here.
</enum>

<tag/type/
<P>
  The content type of the object as seen in the HTTP reply
  header. Please note that ICP exchanges usually don't have any content
  type, and thus are logged ``-''. Also, some weird replies have content
  types ``:'' or even empty ones.
</descrip>

<P>
There may be two more columns in the <em/access.log/, if the (debug) option
<em/log_mime_headers/ is enabled In this case, the HTTP request headers are
logged between a ``['' and a ``]'', and the HTTP reply headers are also
logged between ``['' and ``]''. All control characters like CR and LF are
URL-escaped, but spaces are <em/not/ escaped! Parsers should watch out for
this.

<sect1>Squid result codes
<label id="cache-result-codes">

<P>
The <bf/TCP_/ codes refer to requests on the HTTP port (usually 3128). The
<bf/UDP_/ codes refer to requests on the ICP port (usually 3130). If
ICP logging was disabled using the <em/log_icp_queries/ option, no ICP 
replies will be logged.

<P>
The following result codes were taken from a Squid-2, compare with the
<em/log_tags/ struct in <em>src/access_log.c</em>:

<descrip>

<tag/TCP_HIT/
	A valid copy of the requested object was in the cache.

<tag/TCP_MISS/
	The requested object was not in the cache.

<tag/TCP_REFRESH_HIT/
	The requested object was cached but <em/STALE/. The IMS query
	for the	object resulted in "304 not modified".

<tag/TCP_REF_FAIL_HIT/
	The requested object was cached but <em/STALE/. The IMS query
	failed and the stale object was delivered.

<tag/TCP_REFRESH_MISS/
	The requested object was cached but <em/STALE/. The IMS query
	returned the new content.

<tag/TCP_CLIENT_REFRESH_MISS/<label id="tcp-client-refresh-miss">
	The client issued a "no-cache" pragma, or some analogous cache
	control	command along with the request. Thus, the cache has to
	refetch the object.

<tag/TCP_IMS_HIT/<label id="tcp-ims-hit">
	The client issued an IMS request for an object which was in the
	cache and fresh.

<tag/TCP_SWAPFAIL_MISS/<label id="tcp-swapfail-miss">
	The object was believed to be in the cache,
	but could not be accessed.

<tag/TCP_NEGATIVE_HIT/
	Request for a negatively cached object,
	e.g. "404 not found", for which the cache believes to know that
	it is inaccessible. Also refer to the explainations for
	<em/negative_ttl/ in your <em/squid.conf/ file.

<tag/TCP_MEM_HIT/
	A valid copy of the requested object was in the
	cache <em/and/ it was in memory, thus avoiding disk accesses.

<tag/TCP_DENIED/
	Access was denied for this request.

<tag/TCP_OFFLINE_HIT/
	The requested object was retrieved from the
	cache during offline mode. The offline mode never
	validates any object, see <em/offline_mode/ in
	<em/squid.conf/ file.

<tag/UDP_HIT/
	A valid copy of the requested object was in the cache.

<tag/UDP_MISS/
	The requested object is not in this cache.

<tag/UDP_DENIED/
	Access was denied for this request.

<tag/UDP_INVALID/
	An invalid request was received.

<tag/UDP_MISS_NOFETCH/<label id="udp-miss-nofetch">
	During "-Y" startup, or during frequent
	failures, a cache in hit only mode will return either UDP_HIT or
	this code. Neighbours will thus only fetch hits.

<tag/NONE/
	Seen with errors and cachemgr requests.
</descrip>

<P>
The following codes are no longer available in Squid-2:

<descrip>
<tag/ERR_*/
	Errors are now contained in the status code.

<tag/TCP_CLIENT_REFRESH/
	See: <ref id="tcp-client-refresh-miss" name="TCP_CLIENT_REFRESH_MISS">.

<tag/TCP_SWAPFAIL/
	See: <ref id="tcp-swapfail-miss" name="TCP_SWAPFAIL_MISS">.

<tag/TCP_IMS_MISS/
	Deleted, <ref id="tcp-ims-hit" name="TCP_IMS_HIT"> used instead.

<tag/UDP_HIT_OBJ/
	Hit objects are no longer available.

<tag/UDP_RELOADING/
	See: <ref id="udp-miss-nofetch" name="UDP_MISS_NOFETCH">.
</descrip>

<sect1>HTTP status codes
<label id="http-status-codes">
<P>
These are taken from
<url	url="ftp://ftp.isi.edu/in-notes/rfc2616.txt"
	name="RFC 2616"> and verified for Squid. Squid-2 uses almost all 
codes except 307 (Temporary Redirect), 416 (Request Range Not Satisfiable),
and 417 (Expectation Failed). Extra codes include 0 for a result code being
unavailable, and 600 to signal an invalid header, a proxy error. Also, some
definitions were added as for 
<url	url="ftp://ftp.isi.edu/in-notes/rfc2518.txt"
	name="RFC 2518"> (WebDAV).
Yes, there are really two entries for status code
424, compare with <em/http_status/ in <em>src/enums.h</em>:

<verb>
 000 Used mostly with UDP traffic.

 100 Continue
 101 Switching Protocols
*102 Processing

 200 OK
 201 Created
 202 Accepted
 203 Non-Authoritative Information
 204 No Content
 205 Reset Content
 206 Partial Content
*207 Multi Status

 300 Multiple Choices
 301 Moved Permanently
 302 Moved Temporarily
 303 See Other
 304 Not Modified
 305 Use Proxy
[307 Temporary Redirect]

 400 Bad Request
 401 Unauthorized
 402 Payment Required
 403 Forbidden
 404 Not Found
 405 Method Not Allowed
 406 Not Acceptable
 407 Proxy Authentication Required
 408 Request Timeout
 409 Conflict
 410 Gone
 411 Length Required
 412 Precondition Failed
 413 Request Entity Too Large
 414 Request URI Too Large
 415 Unsupported Media Type
[416 Request Range Not Satisfiable]
[417 Expectation Failed]
*424 Locked
*424 Failed Dependency
*433 Unprocessable Entity

 500 Internal Server Error
 501 Not Implemented
 502 Bad Gateway
 503 Service Unavailable
 504 Gateway Timeout
 505 HTTP Version Not Supported
*507 Insufficient Storage

 600 Squid header parsing error
</verb>

<sect1>Request methods
<label id="request-methods">
<P>
Squid recognizes several request methods as defined in 
<url	url="ftp://ftp.isi.edu/in-notes/rfc2616.txt"
	name="RFC 2616">. Newer versions of Squid (2.2.STABLE5 and above)
also recognize 
<url	url="ftp://ftp.isi.edu/in-notes/rfc2616.txt"
	name="RFC 2518"> ``HTTP Extensions for Distributed Authoring --
WEBDAV'' extensions.

<verb>
 method    defined    cachabil.  meaning
 --------- ---------- ---------- -------------------------------------------
 GET       HTTP/0.9   possibly   object retrieval and simple searches.
 HEAD      HTTP/1.0   possibly   metadata retrieval.
 POST      HTTP/1.0   CC or Exp. submit data (to a program).
 PUT       HTTP/1.1   never      upload data (e.g. to a file).
 DELETE    HTTP/1.1   never      remove resource (e.g. file).
 TRACE     HTTP/1.1   never      appl. layer trace of request route.
 OPTIONS   HTTP/1.1   never      request available comm. options.
 CONNECT   HTTP/1.1r3 never      tunnel SSL connection.

 ICP_QUERY Squid      never      used for ICP based exchanges.
 PURGE     Squid      never      remove object from cache.

 PROPFIND  rfc2518    ?          retrieve properties of an object.
 PROPATCH  rfc2518    ?          change properties of an object.
 MKCOL     rfc2518    never      create a new collection.
 COPY      rfc2518    never	 create a duplicate of src in dst.
 MOVE      rfc2518    never	 atomically move src to dst.
 LOCK      rfc2518    never	 lock an object against modifications.
 UNLOCK    rfc2518    never	 unlock an object.
</verb> 



<sect1>Hierarchy Codes
<label id="hier-codes">
<P>
The following hierarchy codes are used with Squid-2:
<descrip>
<tag/NONE/
	For TCP HIT, TCP failures, cachemgr requests and all UDP
	requests, there is no hierarchy information.

<tag/DIRECT/
	The object was fetched from the origin server.

<tag/SIBLING_HIT/
	The object was fetched from a sibling cache which replied with
	UDP_HIT.

<tag/PARENT_HIT/
	The object was requested from a parent cache which replied with 
	UDP_HIT.

<tag/DEFAULT_PARENT/
	No ICP queries were sent. This parent was chosen because it was
	marked ``default'' in the config file.

<tag/SINGLE_PARENT/
	The object was requested from the only parent appropriate for the 
	given URL.

<tag/FIRST_UP_PARENT/
	The object was fetched from the first parent in the list of
	parents.

<tag/NO_PARENT_DIRECT/
	The object was fetched from the origin server, because no parents
	existed for the given URL.

<tag/FIRST_PARENT_MISS/
	The object was fetched from the parent with the fastest (possibly
	weighted) round trip time. 

<tag/CLOSEST_PARENT_MISS/
	This parent was chosen, because it included the the lowest RTT
	measurement to the origin server. See also the <em/closests-only/
	peer configuration option.

<tag/CLOSEST_PARENT/
	The parent selection was based on our own RTT measurements.

<tag/CLOSEST_DIRECT/
	Our own RTT measurements returned a shorter time than any parent.

<tag/NO_DIRECT_FAIL/
	The object could not be requested because of a firewall
	configuration, see also <em/never_direct/ and related material,
	and no parents were available.

<tag/SOURCE_FASTEST/
	The origin site was chosen, because the source ping arrived fastest.

<tag/ROUNDROBIN_PARENT/
	No ICP replies were received from any parent. The parent was
	chosen, because it was marked for round robin in the config file
	and had the lowest usage count.

<tag/CACHE_DIGEST_HIT/
	The peer was chosen, because the cache digest predicted a
	hit. This option was later replaced in order to distinguish
	between parents and siblings.

<tag/CD_PARENT_HIT/
	The parent was chosen, because the cache digest predicted a
	hit.

<tag/CD_SIBLING_HIT/
	The sibling was chosen, because the cache digest predicted a
	hit.

<tag/NO_CACHE_DIGEST_DIRECT/
	This output seems to be unused?

<tag/CARP/
	The peer was selected by CARP.

<tag/ANY_PARENT/
	part of <em>src/peer_select.c:hier_strings[]</em>.

<tag/INVALID CODE/
	part of <em>src/peer_select.c:hier_strings[]</em>.
</descrip>

<P>
Almost any of these may be preceded by 'TIMEOUT_' if the two-second
(default) timeout occurs waiting for all ICP replies to arrive from
neighbors, see also the <em/icp_query_timeout/ configuration option.

<P>
The following hierarchy codes were removed from Squid-2:
<verb>
code                  meaning
--------------------  -------------------------------------------------
PARENT_UDP_HIT_OBJ    hit objects are not longer available.
SIBLING_UDP_HIT_OBJ   hit objects are not longer available.
SSL_PARENT_MISS	      SSL can now be handled by squid.
FIREWALL_IP_DIRECT    No special logging for hosts inside the firewall.
LOCAL_IP_DIRECT       No special logging for local networks.
</verb>

<sect1><em>cache/log</em> (Squid-1.x)
<label id="swaplog">

<P>
This file has a rather unfortunate name.  It also is often called the
<em/swap log/.  It is a record of every cache object written to disk.
It is read when Squid starts up to ``reload'' the cache.  If you remove
this file when squid is NOT running, you will effectively wipe out your
cache contents.  If you remove this file while squid IS running,
you can easily recreate it.  The safest way is to simply shutdown
the running process:
<verb>
	% squid -k shutdown
</verb>
This will disrupt service, but at least you will have your swap log
back.
Alternatively, you can tell squid to rotate its log files.  This also
causes a clean swap log to be written.
<verb>
	% squid -k rotate
</verb>

<P>
For Squid-1.1, there are six fields:
<enum>
<item>
<bf/fileno/:
The swap file number holding the object data.  This is mapped to a pathname on your filesystem.

<item>
<bf/timestamp/:
This is the time when the object was last verified to be current.  The time is a
hexadecimal representation of Unix time.

<item>
<bf/expires/:
This is the value of the Expires header in the HTTP reply.  If an Expires header
was not present, this will be -2 or fffffffe.  If the Expires header was
present, but invalid (unparsable), this will be -1 or ffffffff.

<item>
<bf/lastmod/:
Value of the HTTP reply Last-Modified header.  If missing it will be -2,
if invalid it will be -1.

<item>
<bf/size/:
Size of the object, including headers.

<item>
<bf/url/:
The URL naming this object.

</enum>

<sect1><em>swap.state</em> (Squid-2.x)
<P>
In Squid-2, the swap log file is now called <em/swap.state/.  This is
a binary file that includes MD5 checksums, and <em/StoreEntry/ fields.
Please see the <url url="../Prog-Guide/" name="Programmers Guide"> for
information on the contents and format of that file.

<p>
If you remove <em/swap.state/ while Squid is running, simply send 
Squid the signal to rotate its log files:
<verb>
	% squid -k rotate
</verb>
Alternatively, you can tell Squid to shutdown and it will
rewrite this file before it exits.

<p>
If you remove the <em/swap.state/ while Squid is not running, you will
not lose your entire cache.  In this case, Squid will scan all of
the cache directories and read each swap file to rebuild the cache.
This can take a very long time, so you'll have to be patient.

<p>
By default the <em/swap.state/ file is stored in the top-level
of each <em/cache_dir/.  You can move the logs to a different
location with the <em/cache_swap_log/ option.


<sect1>Which log files can I delete safely?
<p>
You should never delete <em/access.log/, <em/store.log/,
<em/cache.log/, or <em/swap.state/ while Squid is running.
With Unix, you can delete a file when a process
has the file opened.  However, the filesystem space is
not reclaimed until the process closes the file.

<p>
If you accidentally delete <em/swap.state/ while Squid is running,
you can recover it by following the instructions in the previous
questions.  If you delete the others while Squid is running,
you can not recover them.

<p>
The correct way to maintain your log files is with Squid's ``rotate''
feature.  You should rotate your log files at least once per day.
The current log files are closed and then renamed with numeric extensions
(.0, .1, etc).  If you want to, you can write your own scripts
to archive or remove the old log files.  If not, Squid will
only keep up to <em/logfile_rotate/ versions of each log file.
The logfile rotation procedure also writes a clean <em/swap.state/
file, but it does not leave numbered versions of the old files.

<p>
If you set <em/logfile_rotate/ to 0, Squid simply closes and then
re-opens the logs.  This allows third-party logfile management systems,
such as <em/newsyslog/, to maintain the log files.


<P>
To rotate Squid's logs, simple use this command:
<verb>
	squid -k rotate
</verb>
For example, use this cron entry to rotate the logs at midnight:
<verb>
	0 0 * * * /usr/local/squid/bin/squid -k rotate
</verb>

<sect1>How can I disable Squid's log files?

<p><bf/For Squid 2.4:/

<p>To disable <em/access.log/:
<verb>
        cache_access_log /dev/null
</verb>

<p>To disable <em/store.log/:
<verb>
        cache_store_log none
</verb>

<p>To disable <em/cache.log/:
<verb>
        cache_log /dev/null
</verb>

<p><bf/For Squid 2.5:/

<p>To disable <em/access.log/:
<verb>
        cache_access_log none
</verb>

<p>To disable <em/store.log/:
<verb>
        cache_store_log none
</verb>

<p>To disable <em/cache.log/:
<verb>
        cache_log /dev/null
</verb>

<p>
<bf/Note /: It is a bad idea to disable the <em/cache.log/ because this 
file contains many important status and debugging messages.  However, if 
you really want to, you can.

<p>
<bf/Warning /: If /dev/null is specified to any of the above log files, 
<em/logfile rotate/ must also be set to <em/0/ or else risk Squid 
rotating away /dev/null making it a plain log file.

<p>
<bf/Tip /: Instead of disabling the log files, it is advisable to use a
smaller value for <em/logfile_rotate/ and properly rotating Squid's log
files in your cron. That way, your log files are more controllable and
self-maintained by your system.

<sect1>My log files get very big!
<label id="log-large">
<P>
You need to <em/rotate/ your log files with a cron job.  For example:
<verb>
	0 0 * * * /usr/local/squid/bin/squid -k rotate
</verb>

<sect1>I want to use another tool to maintain the log files.
<p>
If you set <em/logfile_rotate/ to 0, Squid simply closes and then
re-opens the logs.  This allows third-party logfile management systems,
such as <em/newsyslog/, to maintain the log files.

<sect1>Managing log files

<P>
The preferred log file for analysis is the <em/access.log/ file in native
format. For long term evaluations, the log file should be obtained at
regular intervals. Squid offers an easy to use API for rotating log files,
in order that they may be moved (or removed) without disturbing the cache
operations in progress. The procedures were described above.

<P>
Depending on the disk space allocated for log file storage, it is
recommended to set up a cron job which rotates the log files every 24, 12,
or 8 hour. You will need to set your <em/logfile_rotate/ to a sufficiently
large number. During a time of some idleness, you can safely transfer the
log files to your analysis host in one burst.

<P>
Before transport, the log files can be compressed during off-peak time. On
the analysis host, the log file are concatinated into one file, so one file
for 24 hours is the yield. Also note that with <em/log_icp_queries/
enabled, you might have around 1 GB of uncompressed log information per day
and busy cache. Look into you cache manager info page to make an educated
guess on the size of your log files.

<P>
The EU project <url url="http://www.desire.org/" name="DESIRE">
developed some 
<url url="http://www.uninett.no/prosjekt/desire/arneberg/statistics.html" name="some basic rules">
to obey when handling and processing log files:

<itemize>
<item>Respect the privacy of your clients when publishing results.
<item>Keep logs unavailable unless anonymized. Most countries have laws on
 privacy protection, and some even on how long you are legally allowed to
 keep certain kinds of information. 
<item>Rotate and process log files at least once a day. Even if you don't
 process the log files, they will grow quite large, see section
 <ref id="log-large">. If you rely on processing the log files, reserve
 a large enough partition solely for log files.
<item>Keep the size in mind when processing. It might take longer to 
 process log files than to generate them!
<item>Limit yourself to the numbers you are interested in. There is data
 beyond your dreams available in your log file, some quite obvious, others
 by combination of different views. Here are some examples for figures to
 watch:
 <itemize>
 <item>The hosts using your cache.
 <item>The elapsed time for HTTP requests - this is the latency the user
    sees. Usually, you will want to make a distinction for HITs and MISSes
    and overall times. Also, medians are preferred over averages.
 <item>The requests handled per interval (e.g. second, minute or hour). 
 </itemize>
</itemize>


<sect1>Why do I get ERR_NO_CLIENTS_BIG_OBJ messages so often?

<P>
This message means that the requested object was in ``Delete Behind''
mode and the user aborted the transfer.  An object will go into
``Delete Behind'' mode if
<itemize>
<item>It is larger than <em/maximum_object_size/
<item>It is being fetched from a neighbor which has the <em/proxy-only/ option set.
</itemize>

<sect1>What does ERR_LIFETIME_EXP mean?

<P>
This means that a timeout occurred while the object was being transferred.  Most
likely the retrieval of this object was very slow (or it stalled before finishing)
and the user aborted the request.  However, depending on your settings for
<em/quick_abort/, Squid may have continued to try retrieving the object.
Squid imposes a maximum amount of time on all open sockets, so after some amount
of time the stalled request was aborted and logged win an ERR_LIFETIME_EXP
message.

<sect1>Retrieving ``lost'' files from the cache
<P>
<quote><it>
I've been asked to retrieve an object which was accidentally
destroyed at the source for recovery.
So, how do I figure out where the things are so I can copy
them out and strip off the headers?
</it></quote>
<P>
The following method applies only to the Squid-1.1 versions:
<P>
Use <em>grep</em> to find the named object (Url) in the
<ref id="swaplog" name="cache/log"> file.  The first field in
this file is an integer <em/file number/.

<P>
Then, find the file <em/fileno-to-pathname.pl/ from the ``scripts''
directory of the Squid source distribution.  The usage is
<verb>
	perl fileno-to-pathname.pl [-c squid.conf]
</verb>
file numbers are read on stdin, and pathnames are printed on
stdout.

<sect1>Can I use <em/store.log/ to figure out if a response was cachable?
<p>
Sort of.  You can use <em/store.log/ to find out if a particular response
was <em>cached</em>.
<p>
Cached responses are logged with the SWAPOUT tag.
Uncached responses are logged with the RELEASE tag.
<p>
However, your
analysis must also consider that when a cached response is removed
from the cache (for example due to cache replacement) it is also
logged in <em/store.log/ with the RELEASE tag.  To differentiate these
two, you can look at the filenumber (3rd) field.  When an uncachable
response is released, the filenumber is FFFFFFFF (-1).  Any other
filenumber indicates a cached response was released.


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<sect>Operational issues

<sect1>How do I see system level Squid statistics?
<P>
The Squid distribution includes a CGI utility called <em/cachemgr.cgi/
which can be used to view squid statistics with a web browser.
This document has a section devoted to <em/cachemgr.cgi/ usage
which you should consult for more information.

<sect1>How can I find the biggest objects in my cache?
<P>
<verb>
	sort -r -n +4 -5 access.log | awk '{print $5, $7}' | head -25
</verb>

<sect1>I want to restart Squid with a clean cache
<p>
<em>Note: The information here is current for version 2.2.</em>
<P>
First of all, you must stop Squid of course.  You can use
the command:
<verb>
	% squid -k shutdown
</verb>

<p>
The fastest way to restart with an entirely clean cache is
to over write the <em/swap.state/ files for each <em/cache_dir/
in  your config file.  Note, you can not just remove the
<em/swap.state/ file, or truncate it to zero size.  Instead,
you should put just one byte of garbage there.  For example:
<verb>
	% echo "" > /cache1/swap.state
</verb>
Repeat that for every <em/cache_dir/, then restart Squid.
Be sure to leave the <em/swap.state/ file with the same
owner and permissions that it had before!

<p>
Another way, which takes longer, is to have squid recreate all the
<em/cache_dir/ directories.  But first you must move the existing
directories out of the way.  For example,  you can try this:
<verb>
	% cd /cache1
	% mkdir JUNK
	% mv ?? swap.state* JUNK
	% rm -rf JUNK &
</verb>
Repeat this for your other <em/cache_dir/'s, then tell Squid
to create new directories:
<verb>
	% squid -z
</verb>

<sect1>How can I proxy/cache Real Audio?

<P>
by <url url="mailto:roever@nse.simac.nl" name="Rodney van den Oever">,
and <url url="mailto:jrg@blodwen.demon.co.uk" name="James R Grinter">

<P>
<itemize>

<item>
Point the RealPlayer at your Squid server's HTTP port (e.g. 3128).

<item>
Using the Preferences->Transport tab, select <em/Use specified transports/
and with the <em/Specified Transports/ button, select use <em/HTTP Only/.
</itemize>

The RealPlayer (and RealPlayer Plus) manual states:
<verb>
Use HTTP Only
	Select this option if you are behind a firewall and cannot
	receive data through TCP.  All data will be streamed through
	HTTP.

	Note:  You may not be able to receive some content if you select
	this option.
</verb>

<P>
Again, from the documentation:
<verb>
RealPlayer 4.0 identifies itself to the firewall when making a
request for content to a RealServer.  The following string is
attached to any URL that the Player requests using HTTP GET:

	/SmpDsBhgRl

Thus, to identify an HTTP GET request from the RealPlayer, look
for:

	http://[^/]+/SmpDsBhgRl

The Player can also be identified by the mime type in a POST to
the RealServer.  The RealPlayer POST has the following mime
type:

	"application/x-pncmd"
</verb>

Note that the first request is a POST, and the second has a '?' in the URL, so
standard Squid configurations would treat it as non-cachable. It also looks
rather ``magic.''

<P>
HTTP is an alternative delivery mechanism introduced with version 3 players,
and it allows a reasonable approximation to ``streaming'' data - that is playing
it as you receive it.  

<P>
It isn't available in the general case: only if someone has made the realaudio
file available via an HTTP server, or they're using a version 4 server, they've
switched it on, and you're using a version 4 client. If someone has made the
file available via their HTTP server, then it'll be cachable. Otherwise, it
won't be (as far as we can tell.)

<P>
The more common RealAudio link connects via their own <em/pnm:/ method and is
transferred using their proprietary protocol (via TCP or UDP) and not using
HTTP. It can't be cached nor proxied by Squid, and requires something such as
the simple proxy that Progressive Networks themselves have made available, if
you're in a firewall/no direct route situation. Their product does not cache
(and I don't know of any software available that does.)

<P>
Some confusion arises because there is also a configuration option to use an
HTTP proxy (such as Squid) with the Realaudio/RealVideo players. This is
because the players can fetch the ``<tt/.ram/'' file that contains the <em/pnm:/
reference for the audio/video stream. They fetch that .ram file from an HTTP
server, using HTTP.

<sect1>How can I purge an object from my cache?
<label id="purging-objects">

<P>
Squid does not allow
you to purge objects unless it is configured with access controls
in <em/squid.conf/.  First you must add something like
<verb>
	acl PURGE method PURGE
	acl localhost src 127.0.0.1
	http_access allow PURGE localhost
	http_access deny PURGE
</verb>
The above only allows purge requests which come from the local host and
denies all other purge requests.

<P>
To purge an object, you can use the <em/squidclient/ program:
<verb>
	squidclient -m PURGE http://www.miscreant.com/
</verb>
If the purge was successful, you will see a ``200 OK'' response:
<verb>
	HTTP/1.0 200 OK
	Date: Thu, 17 Jul 1997 16:03:32 GMT
	Server: Squid/1.1.14
</verb>
If the object was not found in the cache, you will see a ``404 Not Found''
response:
<verb>
	HTTP/1.0 404 Not Found
	Date: Thu, 17 Jul 1997 16:03:22 GMT
	Server: Squid/1.1.14
</verb>



<sect1>Using ICMP to Measure the Network
<label id="using-icmp">
<P>
As of version 1.1.9, Squid is able to utilize ICMP Round-Trip-Time (RTT)
measurements to select the optimal location to forward a cache miss.
Previously, cache misses would be forwarded to the parent cache
which returned the first ICP reply message.  These were logged
with FIRST_PARENT_MISS in the access.log file.  Now we can
select the parent which is closest (RTT-wise) to the origin
server.

<sect2>Supporting ICMP in your Squid cache

<P>
    It is more important that your parent caches enable the ICMP
    features.  If you are acting as a parent, then you may want
    to enable ICMP on your cache.  Also, if your cache makes
    RTT measurements, it will fetch objects directly if your
    cache is closer than any of the parents.

<P>
    If you want your Squid cache to measure RTT's to origin servers,
    Squid must be compiled with the USE_ICMP option.  This is easily
    accomplished by uncommenting "-DUSE_ICMP=1" in <em>src/Makefile</em> and/or
    <em>src/Makefile.in</em>.

<P>
    An external program called <em/pinger/ is responsible for sending and
    receiving ICMP packets.  It must run with root privileges.  After
    Squid has been compiled, the pinger program must be installed
    separately.  A special Makefile target will install <em/pinger/ with
    appropriate permissions.
<verb>
	% make install
	% su
	# make install-pinger
</verb>
    There are three configuration file options for tuning the
    measurement database on your cache.  <em/netdb_low/ and <em/netdb_high/
    specify high and low water marks for keeping the database to a
    certain size  (e.g. just like with the IP cache).  The <em/netdb_ttl/
    option specifies the minimum rate for pinging a site.  If
    <em/netdb_ttl/ is set to 300 seconds (5 minutes) then an ICMP packet
    will not be sent to the same site more than once every five
    minutes.  Note that a site is only pinged when an HTTP request for
    the site is received.
<P>
    Another option, <em/minimum_direct_hops/ can be used to try finding
    servers which are close to your cache.  If the measured hop count
    to the origin server is less than or equal to <em/minimum_direct_hops/,
    the request will be forwarded directly to the origin server.

<sect2>Utilizing your parents database
<P>
    Your parent caches can be asked to include the RTT measurements
    in their ICP replies.  To do this, you must enable <em/query_icmp/
    in your config file:
<verb>
	query_icmp on
</verb>
    This causes a flag to be set in your outgoing ICP queries.
<P>
    If your parent caches return ICMP RTT measurements then
    the eighth column of your access.log will have lines
    similar to:
<verb>
	CLOSEST_PARENT_MISS/it.cache.nlanr.net
</verb>
    In this case, it means that <em/it.cache.nlanr.net/ returned
    the lowest RTT to the origin server.  If your cache measured
    a lower RTT than any of the parents, the request will
    be logged with
<verb>
	CLOSEST_DIRECT/www.sample.com
</verb>

<sect2>Inspecting the database
<P>
    The measurement database can be viewed from the cachemgr by
    selecting "Network Probe Database."  Hostnames are aggregated
    into /24 networks.  All measurements made are averaged over
    time.  Measurements are made to specific hosts, taken from
    the URLs of HTTP requests.  The recv and sent fields are the
    number of ICMP packets sent and received.  At this time they
    are only informational.
<P>
    A typical database entry looks something like this:
<verb>
    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
</verb>
    This means we have sent 21 pings to both www.jisedu.org and
    www.dozo.com.  The average RTT is 82.3 milliseconds.  The
    next four lines show the measured values from our parent
    caches.  Since <em/bo.cache.nlanr.net/ has the lowest RTT,
    it would be selected as the location to forward a request
    for a www.jisedu.org or www.dozo.com URL.

<sect1>Why are so few requests logged as TCP_IMS_MISS?

<P>
When Squid receives an <em/If-Modified-Since/ request, it will
not forward the request unless the object needs to be refreshed
according to the <em/refresh_pattern/ rules.  If the request
does need to be refreshed, then it will be logged as TCP_REFRESH_HIT
or TCP_REFRESH_MISS.

<P>
If the request is not forwarded, Squid replies to the IMS request
according to the object in its cache.  If the modification times are the
same, then Squid returns TCP_IMS_HIT.  If the modification times are
different, then Squid returns TCP_IMS_MISS.  In most cases, the cached
object will not have changed, so the result is TCP_IMS_HIT.  Squid will
only return TCP_IMS_MISS if some other client causes a newer version of
the object to be pulled into the cache.

<sect1>How can I make Squid NOT cache some servers or URLs?

<P>
In Squid-2, you use the <em/no_cache/ option to specify uncachable
requests.  For example, this makes all responses from origin servers
in the 10.0.1.0/24 network uncachable:
<verb>
	acl Local dst 10.0.1.0/24
	no_cache deny Local
</verb>

<p>
This example makes all URL's with '.html' uncachable:
<verb>
	acl HTML url_regex .html$
	no_cache deny HTML
</verb>

<p>
This example makes  a specific URL uncachable:
<verb>
	acl XYZZY url_regex ^http://www.i.suck.com/foo.html$
	no_cache deny XYZZY
</verb>

<p>
This example caches nothing between the hours of 8AM to 11AM:
<verb>
	acl Morning time 08:00-11:00
	no_cache deny Morning
</verb>

<P>
In Squid-1.1,
whether or not an object gets cached is controlled by the
<em/cache_stoplist/, and <em/cache_stoplist_pattern/ options.  So, you may add:
<verb>
	cache_stoplist my.domain.com
</verb>
Specifying uncachable objects by IP address is harder.  The <url url="../1.1/patches.html"
name="1.1 patch page"> includes a patch called <em/no-cache-local.patch/ which
changes the behaviour of the <em/local_ip/ and <em/local_domain/ so
that matching requests are NOT CACHED, in addition to being fetched directly.

<sect1>How can I delete and recreate a cache directory?

<P>
Deleting an ex