Squid configuration manual

Reference manual for squid's configuraiton directives

View the Project on GitHub

Index Alphabetical Index

Option Name:

cache_dir

Suggested Config:


Details:

Format:
	cache_dir Type Directory-Name Fs-specific-data [options]

You can specify multiple cache_dir lines to spread the
cache among different disk partitions.

Type specifies the kind of storage system to use. Only "ufs"
is built by default. To enable any of the other storage systems
see the --enable-storeio configure option.

'Directory' is a top-level directory where cache swap
files will be stored.  If you want to use an entire disk
for caching, this can be the mount-point directory.
The directory must exist and be writable by the Squid
process.  Squid will NOT create this directory for you.

Rock is currently the only SMP-aware cache_dir type. Using other
store types in configurations with multiple workers is not
supported and may lead to HTTP violations or undefined behavior,
even when each such cache_dir is given a dedicated worker using
configuration conditionals.


====  The ufs store type  ====

"ufs" is the old well-known Squid storage format that has always
been there.

Usage:
	cache_dir ufs Directory-Name Mbytes L1 L2 [options]

'Mbytes' is the amount of disk space (MB) to use under this
directory.  The default is 100 MB.  Change this to suit your
configuration.  Do NOT put the size of your disk drive here.
Instead, if you want Squid to use the entire disk drive,
subtract 20% and use that value.

'L1' is the number of first-level subdirectories which
will be created under the 'Directory'.  The default is 16.

'L2' is the number of second-level subdirectories which
will be created under each first-level directory.  The default
is 256.


====  The aufs store type  ====

"aufs" uses the same storage format as "ufs", utilizing
POSIX-threads to avoid blocking the main Squid process on
disk-I/O. This was formerly known in Squid as async-io.

Usage:
	cache_dir aufs Directory-Name Mbytes L1 L2 [options]

see argument descriptions under ufs above


====  The diskd store type  ====

"diskd" uses the same storage format as "ufs", utilizing a
separate process to avoid blocking the main Squid process on
disk-I/O.

Usage:
	cache_dir diskd Directory-Name Mbytes L1 L2 [options] [Q1=n] [Q2=n]

see argument descriptions under ufs above

Q1 specifies the number of unacknowledged I/O requests when Squid
stops opening new files. If this many messages are in the queues,
Squid won't open new files. Default is 64

Q2 specifies the number of unacknowledged messages when Squid
starts blocking.  If this many messages are in the queues,
Squid blocks until it receives some replies. Default is 72

When Q1 < Q2 (the default), the cache directory is optimized
for lower response time at the expense of a decrease in hit
ratio.  If Q1 > Q2, the cache directory is optimized for
higher hit ratio at the expense of an increase in response
time.


====  The rock store type  ====

Usage:
    cache_dir rock Directory-Name Mbytes [options]

The Rock Store type is a database-style storage. All cached
entries are stored in a "database" file, using fixed-size slots.
A single entry occupies one or more slots.

If possible, Squid using Rock Store creates a dedicated kid
process called "disker" to avoid blocking Squid worker(s) on disk
I/O. One disker kid is created for each rock cache_dir.  Diskers
are created only when Squid, running in daemon mode, has support
for the IpcIo disk I/O module.

swap-timeout=msec: Squid will not start writing a miss to or
reading a hit from disk if it estimates that the swap operation
will take more than the specified number of milliseconds. By
default and when set to zero, disables the disk I/O time limit
enforcement. Ignored when using blocking I/O module because
blocking synchronous I/O does not allow Squid to estimate the
expected swap wait time.

max-swap-rate=swaps/sec: Artificially limits disk access using
the specified I/O rate limit. Swap out requests that
would cause the average I/O rate to exceed the limit are
delayed. Individual swap in requests (i.e., hits or reads) are
not delayed, but they do contribute to measured swap rate and
since they are placed in the same FIFO queue as swap out
requests, they may wait longer if max-swap-rate is smaller.
This is necessary on file systems that buffer "too
many" writes and then start blocking Squid and other processes
while committing those writes to disk.  Usually used together
with swap-timeout to avoid excessive delays and queue overflows
when disk demand exceeds available disk "bandwidth". By default
and when set to zero, disables the disk I/O rate limit
enforcement. Currently supported by IpcIo module only.

slot-size=bytes: The size of a database "record" used for
storing cached responses. A cached response occupies at least
one slot and all database I/O is done using individual slots so
increasing this parameter leads to more disk space waste while
decreasing it leads to more disk I/O overheads. Should be a
multiple of your operating system I/O page size. Defaults to
16KBytes. A housekeeping header is stored with each slot and
smaller slot-sizes will be rejected. The header is smaller than
100 bytes.


==== COMMON OPTIONS ====

no-store	no new objects should be stored to this cache_dir.

min-size=n	the minimum object size in bytes this cache_dir
		will accept.  It's used to restrict a cache_dir
		to only store large objects (e.g. AUFS) while
		other stores are optimized for smaller objects
		(e.g. Rock).
		Defaults to 0.

max-size=n	the maximum object size in bytes this cache_dir
		supports.
		The value in maximum_object_size directive sets
		the default unless more specific details are
		available (ie a small store capacity).

Note: To make optimal use of the max-size limits you should order
the cache_dir lines with the smallest max-size value first.

# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /usr/local/squid/var/cache/squid 100 16 256
Index Alphabetical Index