Apt-cacher is a way to setup a repository cache server on your network. Once a package is downloaded from an official repository, all other machines will be able to download it from this server in the LAN. This will reduce the network traffic as well as speed up the process of updating or upgrading your Ubuntu.
bash$ sudo aptitude install apt-cacher
After the installation, go edit the /etc/apt-cacher/apt-cacher.conf according to your preference. Here are some of the common setting options:
daemon_port is the value to set the port for running apt-cacher daemon. The default is 3142.
admin_email is the email address of the administrator in the info page and traffic reports.
allow_hosts by default allow all hosts to use the repository cache server. You can change this to your LAN network (192.168.0.0/24) and your localhost (127.0.0.1). So the setting would be:
allow_hosts=192.168.0.0/24, 127.0.0.1
generate_reports create a report on how efficient your cache is being utilize on a daily basis. The default is 1, if you want to disable it, set it to 0.
In order to start apt-cacher automatically, you have to set the value of AUTOSTART to 1 in /etc/default/apt-cacher. Now restart the apt-cacher to have it take the new setting.
bash$ sudo /etc/init.d/apt-cacher restart
There are 2 ways to configure your clients to use apt-cacher. I would recommend using the Proxy since you won't be modifying the source.list. But if the proxy way doesn't work, you can try the alternate.
Using a proxy
Add a file to the apt configuration:
bash$ sudo vi /etc/apt/apt.conf.d/01proxy
Inside this file, add this line:
Acquire::http::Proxy "http://apt-cacher-server:3142";
Modifying source.list File
Set a name to the apt-cacher server by editing the /etc/hosts file. For example, if your server IP address is 192.168.0.50 and you want it to name it apt-cacher-server, add this to the /etc/hosts file:
192.168.0.50 apt-cacher-server
To setup the aptitude to use the apt-cacher, edit the /etc/apt/source.list file. But first, make a back up copy of it. I usually name it source.list.default. Here is the original sample of the /etc/apt/source.list file:
deb http://us.archive.ubuntu.com/ubuntu/ karmic main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic main restricted
In order to use the apt-cacher server repository, these entries need to be changed to:
deb http://apt-cacher-server:3142/us.archive.ubuntu.com/ubuntu/ karmic main restricted
deb-src http://apt-cacher-server:3142/us.archive.ubuntu.com/ubuntu/ karmic main restricted
Now let do a test run by updating the repository:
bash$ sudo LANG=C aptitude update
If you left the directive generate_reports set to 1, apt-cacher will generate report on the usage of the cache on the daily basis. You will be able to access it via: http://apt-cacher-server:3142/report