Manpages

NAME

apt-cacher − caching proxy for Debian packages

SYNOPSIS

http://proxy.example.com/apt-cacher/ [mirror] / [distribution]

DESCRIPTION

Apt-cacher is a caching proxy for Debian packages, allowing a number of computers to share a single local cache. Packages requested from the cache only need to be downloaded from the Debian mirrors once, no matter how many local machines need to install them. This saves internet bandwidth and improves performance for local users, and reduces the load on the mirrors. More information is available on the Apt-cacher web site at www.apt-cacher.org.

Setting up apt-cacher involves two stages: installing apt-cacher itself on a single machine on your network, and configuring all local machines to use the cache.

The cache machine needs apt-cacher installed, which runs as a CGI under Apache. When Apt requests a package from the cache machine, the request is handled by apt-cacher which checks whether it already has that particular package. If so, the package is returned immediately to Apt for installation. If not, or if the package in the local cache has been superseded by a more recent version, the package is fetched from the specified mirror. While being fetched it is simultaneously streamed to Apt, and also saved to the local cache for future use.

Other machines on your network do not need apt-cacher installed in order to use the local cache. The only modification to each client computer is to prepend the cache machine’s address and an ’/apt-cacher’ extension to each HTTP mirror in /etc/apt/sources.list. Apt then sends all its package requests to the cache machine, rather than directly to the mirror.

For example, if you have a line in your sources.list that looks like this:

deb http://mirror.aarnet.edu.au/debian unstable main contrib non-free

You would add ’proxy.example.com/apt-cacher’ at the start to make it look like this:

deb http://proxy.example.com/apt-cacher/mirror.aarnet.edu.au/debian unstable main contrib non-free

where ’proxy.example.com’ is the address of the computer running your apt-cacher cache.

Apt-cacher currently only handles HTTP requests.

OPTIONS

Apt-cacher uses a configuration file for setting all options. The configuration file is installed by default as /etc/apt-cacher/apt-cacher.conf. The options available in the conf file (and their default settings) are:
cache_dir [/var/cache/apt-cacher]

The directory where apt-cacher will store local copies of all packages requested. This can grow to many hundreds of MB, so make sure it is on a partition with plenty of room.

admin_email [root@localhost]

The email address of the administrator is displayed in the info page and traffic reports.

allowed_hosts [*]

If your apt-cacher machine is directly exposed to the Internet and you are worried about unauthorised machines fetching packages through it, you can specify a range of IP addresses that are allowed to use it. Localhost (127.0.0.1) is explicitly always allowed, and if you want to allow all addresses you can use ’*’. Otherwise the format should be a range of addresses from a start address to an end address, like ’allowed_hosts=192.168.0.3-192.168.0.56’. Note that by default apt-cacher will allow requests from any client, so set a range here if you want to restrict access.

generate_reports [1]

Whether to generate traffic reports daily. Traffic reports can be accessed by pointing a browser to http://proxy.example.com/apt-cacher/report/ (using the address of your own cache of course).

clean_cache [1]

Whether to flush old packages from your cache daily. Packages are deleted on the basis of whether they have been superseded by newer packages, not on age, so it should be safe to leave this on.

logdir [/var/log/apt-cacher]

Directory to use for the access and error log files and traffic report. The access log records all successful package requests using a timestamp, whether the request was fulfilled from cache, the IP address of the requesting computer, the size of the package transferred, and the name of the package. The error log records major faults, and is also used for debug messages if the debug directive is set to 1.

expire_hours [36]

How many hours Package and Release files are cached before they are assumed to be too old and must be re-fetched.

http_proxy [proxy.example.com:8080]

Apt-cacher can pass all its requests to an external http proxy like Squid, which could be very useful if you are using an ISP that blocks port 80 and requires all web traffic to go through its proxy. The format is ’hostname:port’, eg: ’proxy.example.com:8080’.

use_proxy [0]

Use of an external proxy can be turned on or off with this flag. Value should be either 0 (off) or 1 (on):

limit [0]

Rate limiting sets the maximum bandwidth in bytes per second to use for fetching packages. Syntax is fully defined in ’man wget’. Use ’k’ or ’m’ to use kilobits or megabits / second: eg, ’limit=25k’. Use 0 or a negative value for no rate limiting.

debug [0]

Whether debug mode is enabled. Off by default. When turned on, lots of extra debug junk will be spewed to the error log. This can make the error log become quite big, so only use it when trying to debug problems.

THE MOST FAQ IN HISTORY:

Q: Can I just copy some .debs into the cache dir and have it work?

A: Yes! No! Almost!

Apt-cacher stores debs in the cache dir with the HTTP headers prepended and relies on them when sending to clients. It also uses a little flag file to keep track of which packages are completely downloaded. If you copy .debs straight in and don’t fix those things up, fetching them *will* fail.

However, Apt-cacher now comes with an import helper script to make things easier. Just put a bunch of .debs into /var/cache/apt-cacher/import (or a directory called ’import’ inside whatever you’ve set your cache dir to be, and run /usr/share/apt-cacher/apt-cacher-import.pl. The script will run through all the .debs it finds in that dir and set them up for you in the cache.

AUTHOR

Apt-cacher was originally written by Nick Andrews <nick [AT] zeta.au>. This manual page was written by Jonathan Oxer <jon [AT] debian.org>, for the Debian GNU/Linux system (but may be used by others). More information is available at www.apt-cacher.org.