Tuesday, 7 July 2015

Don't cache repomd.xml when using squid

If, like me, you try to ensure all your package update traffic goes through a caching proxy, you may occasionally have hit an issue where yum/dnf is trying to download repo metadata which doesn't exist. This can happen because your proxy is caching repomd.xml, and the cached version refers to metadata which has since been deleted.

Fortunately repomd.xml is normally very small, typically less than 4k, so the simplest solution is just not to cache it. You can do that be adding the following stanza to squid.conf:
acl repomd url_regex /repomd\.xml$
cache deny repomd

1 comment:

  1. And if you're on the other side and are hosting repositories that people access through caches, you may want to use mod_expires or similar to stop it being cached to prevent 404s on repodata updates.

    e.g. https://github.com/theforeman/foreman-infra/commit/057b0486e4ba942932aeeb6a0753c0f686970797