Saving time and bandwidth with apt-cacher

Saving time and bandwidth are two things every system administrator loves. Implementing apt-cacher could save you a considerable amount of both, depending on the number of servers you have. As the name implies, apt-cacher caches packages and package lists for apt packaging systems on Debian or Debian-like systems. Here's how I recently implemented apt-cacher:

apt-get install apt-cacher

I edited /etc/apt-cacher/apt-cacher.conf:

cache_dir=/path/to/cache/directory
admin_email=your@email.com
daemon_addr=IPADDRESS

I also edited /etc/default/apt-cacher and set:

AUTOSTART=1

Then ran:

/etc/init.d/apt-cacher start

I imported the existing files apt-get had locally archived:

/usr/share/apt-cacher/apt-cacher-import.pl -r /var/cache/apt/archives

Finally, I edited /etc/apt/sources.list on the apt-cacher server, and each client server:

deb http://hostname:3142/ftp.us.debian.org/debian/ lenny main non-free contrib
deb-src http://hostname:3142/ftp.us.debian.org/debian/ lenny main non-free contrib
 
deb http://hostname:3142/security.debian.org/ lenny/updates main non-free contrib
deb-src http://hostname:3142/security.debian.org/ lenny/updates main non-free contrib

2 thoughts on “Saving time and bandwidth with apt-cacher

  1. neg

    You can also add the following to /etc/apt/apt.conf:

    Acquire::http::Proxy "http://hostname:3142/apt-cacher";

    I find this to be cleaner, rather than having to edit each repos entry in sources.list.

    (It does mean all requests would be via the apt-cacher host, but I don't find that to be an issue)

Leave a Reply

Your email address will not be published. Required fields are marked *