diff --git a/lib/ansible/galaxy/api.py b/lib/ansible/galaxy/api.py index 85c4331e215..cb182f7d7d0 100644 --- a/lib/ansible/galaxy/api.py +++ b/lib/ansible/galaxy/api.py @@ -379,6 +379,7 @@ class GalaxyAPI: # The cache entry had expired or does not exist, start a new blank entry to be filled later. expires = datetime.datetime.now(datetime.timezone.utc) expires += datetime.timedelta(days=1) + server_cache.pop(cache_key, None) headers = headers or {} self._add_auth_token(headers, url, required=auth_required) @@ -400,7 +401,7 @@ class GalaxyAPI: % (resp.url, to_native(resp_data))) if cache and self._cache: - if not valid: + if not valid and not is_paginated_url: server_cache[cache_key] = { 'expires': expires.strftime(iso_datetime_format), 'paginated': False,