DNF expiration check

How to change DNF’s metadata expiration time?
i usually run update once a week but usually search about packages via DNF so there’s no need to refresh repos few times a day. Then how can i increase expiration date to something like 48 hours?


the metadata_expire configuration in the repository configuration files is used to set this. The config files are in /etc/yum.repos.d/, so you’ll need to edit them there.


This seems a misunderstanding of fedora. Packages are often updated, sometimes daily or more often, so keeping old metadata on hand may not see the current packages as the metadata would be stale.

This stale metadata is the reason it is often suggested that you run dnf upgrade --refresh so the update is done with current metadata info. Stale metadata would not see the recent updates.

I just checked /etc/yum.repos.d/fedora.repo and found metadata_expire=7d so your concern about at least 48 hours is already exceeded by that value.

1 Like

You may want to consider running searches with -C or --cacheonly


I’d rather add undermentioned option to /etc/dnf/dnf.conf


    time in seconds

    The minimal period between two consecutive makecache timer runs. The command will stop immediately if it’s less than this time period since its last run. Does not affect simple makecache run. Use 0 to completely disable automatic metadata synchronizing. The default corresponds to three hours. The value is rounded to the next commenced hour.


Making metadata expire after long time may (i think) cause package download errors (if package you’re trying to install turns out replaced in updates repository since last metadata update). metadata_timer_sync with bigger value will still allow to function normally between automatic metadata updates (if you install anything, dnf will download fresh metadata).

Metadata synchronization is started by dnf-makecache.timer, you could disable it, copy to ~/.local/share/systemd/, change it’s name, edit timer settings and enable it. That way you can have it updated exactly when you need it.

Anther thought is that now, with zchunk enabled, consecutive metadata updates are super small, but if you skip week’s worth of updates, dnf might be forced to download full metadata files (~30 MB for updates) instead of only few little zchunk incremental updates.


I see the default setting for that timer is 3 hours, so that is obviously one way to extend the automatic metadata refresh.

yes, for fedora.repo it is something like 7 days, but I assume that the update repo fedora-updates.repo is set to 6 hours, no?

No assumptions to it. The default appears to be


But as stated the time can be changed in either of those locations.