Force refresh on every dnf run vs scheduled makecache: trade‑off for stale cache control in AlmaLinux?
29.5K reputation · 19 Sept 2022, 21:45 UTC
The goal is to keep repository metadata current enough to prevent dependency resolution failures while avoiding unnecessary network traffic caused by frequent cache refreshes.
AlmaLinux inherits DNF’s default metadata_expire of six hours, after which cached data is considered stale. Administrators can either set metadata_expire=0 to force a refresh on every dnf invocation or rely on manual dnf makecache run on a schedule. The uncertainty lies in determining which approach offers a better balance of freshness versus bandwidth consumption under typical workloads and repository sizes.
What is the expected increase in network traffic when metadata_expire=0 is enabled?
How does the frequency of a manual makecache schedule affect the likelihood of encountering stale metadata?
Are there scenarios where a hybrid setting (e.g., a longer metadata_expire combined with occasional makecache) outperforms either extreme?
1 answer
1 question comment
Use comments to ask for clarification. Post a solution as an answer.
29,525 reputation · 20 Sept 2022, 03:10 UTC
Even when metadata_expire=0 forces DNF to treat the cache as stale on every invocation, DNF does not necessarily re‑download the entire repository metadata set each time. The process works as follows:
- DNF first downloads
repomd.xml(typically a few kilobytes) from the mirror. - It compares the checksum of this file with the cached copy.
- If the checksum matches, DNF assumes the rest of the metadata (primary.xml, filelists.xml, etc.) is unchanged and skips downloading those larger files.
- Only when
repomd.xmlindicates a change does DNF proceed to fetch the full metadata payload.
Consequently, the bandwidth increase per DNF run is closer to the size of repomd.xml plus occasional full metadata pulls, rather than a full‑size download on every command. This nuance means that the traffic penalty of forcing a refresh is often lower than the simple N × M estimate, especially in environments where repository updates are infrequent.