Warning : This version of IntelligentMirror is compatible with only squid-2.7 as of now. It is NOT compatible even with squid-3.0.
IntelligentMirror Version 1.0.1
I have been following squid development regularly (at least the part in which I am interested) and they have introduced a new directive in squid-2.7 known as StoreUrlRewrite (storeurl_rewrite_program). Using this directive you can instruct squid to cache url A (http://abc.com/foo/bar/version/crap.rpm) as url B (http://proxy.fedora.co.in/intelligentmirror/crap.rpm). In simple words you can direct squid to cache any url as any other url without any extra efforts.
So keeping the above directive in mind, I have worked out a different version of intelligentmirror especially for squid-2.7.
IntelligentMirror : Old method of operation
- IntelligentMirror gets a client request for a URL.
- Check: if URL is not in (RPM, metadata file)
- Then its none of our business.
- Let proxy handle it the normal way.
- Done and exit.
- Check: if RPM/metadata is available in cache
- Stream the RPM/metadata from cache.
- Done and exit.
- Check: if RPM/metadata is not available in cache
- Download in parallel for caching in some dir and stream.
- Done and exit.
IntelligentMirror : New method of operation
- IntelligentMirror gets a client request for a URL.
- Check: if request for rpm
- Direct squid to cache the request as http://<same_host_all_the_time>/intelligentmirror/<rpmname>.rpm
- Check: if request for deb
- Direct squid to cache the request as http://<same_host_all_the_time>/intelligentmirror/<debname>.deb
- Done and exit.
So your squid will see every request for an rpm package as a request http://<same_host_all_the_time>/intelligentmirror/<rpmname>.rpm. So, if you happen to request the same rpm from a different mirror, it’ll still be served from cache 🙂
Improvements
- No need to check if the url supplied by squid is for rpm or not because storeurl_rewrite_program has an acl controller attached which will invoke intelligentmirror for urls ending in .rpm .
- No need to check if the url is already cached or not. No need to worry about the directory where you are going to store the packages. No human intervention is needed in maintaining the cache. Almighty squid is doing everything for us.
- No need to worry if the target package has changed because of the resigning or whatever because squid will do that for you.
- No need to actually download the package in parallel for caching because squid is already doing that.
- No need to worry about the hashing algorithms and storage optimizations for the cached content.
Availability
Install and Configure
The install and configure files should be enough to guide you through the installation if you choose the tar ball way. Otherwise you can always install from rpm from the above link.
Note1: You have to configure your squid to use intelligentmirror as a plugin even if you install via rpm. Check the configure file at the above link.
Note2: StoreUrlRewrite will probably be available in squid-3.1.