You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Artifactory PyPI代理缓存过期致pip安装失败,为何pip不触发更新?

Why Doesn't pip install Trigger Artifactory Upstream Refresh When PyPI Proxy Cache Expires?

Let me break down what's happening here and why you're seeing this discrepancy between pip and curl/browser requests.

The Core Issue: Request Path & Artifactory Cache Handling Differences

Your problem boils down to how Artifactory handles two distinct types of requests related to PyPI packages, and how pip interacts with those endpoints compared to direct curl/browser calls:

  1. pip's Request Flow: When you run pip install -i https://myartifactory.net/api/pypi/virt/simple requests, pip is querying the PyPI Simple API endpoint (/api/pypi/virt/simple/requests/). This endpoint returns a list of available package versions formatted for pip to parse.

  2. Direct curl/Browser Requests: When you hit https://myartifactory.net/virt/.pypi/requests.html, you're accessing Artifactory's internal package details page, which is a different endpoint than the Simple API.

Artifactory's proxy cache treats these two endpoints differently when cached content expires:

  • For the .pypi/module_name.html endpoint: When the cached entry expires, Artifactory detects the stale content and automatically triggers a refresh from the upstream PyPI repository. This updates the cache with the latest package data.
  • For the Simple API /simple/module_name/ endpoint: By default, Artifactory may not automatically refresh the cached index entry when it expires. Instead, it returns the stale (empty or incomplete) index to pip, which then interprets this as "no matching versions found."

Additional Factor: Request Headers

Another possible angle is the request headers sent by pip vs. curl:

  • pip sends specific cache-related headers (like If-Modified-Since or Cache-Control: max-age=0) when querying the Simple API. In some Artifactory configurations, these headers can cause the system to return a 404 or stale data instead of triggering an upstream refresh for expired cache entries.
  • curl and browsers typically send simpler headers, which don't trigger this restrictive behavior, prompting Artifactory to refresh the cache immediately.

Fixes to Resolve This

Here are actionable steps to make pip install trigger upstream refreshes automatically when cache expires:

  • Adjust Proxy Cache Expiration Settings
    In your Artifactory PyPI proxy repository settings, look for options related to cache refresh on expiration. Enable the setting that tells Artifactory to fetch fresh content from upstream when cached data is stale, rather than returning a 404 or stale index. You can also tweak the cache TTL (time-to-live) values to match your update frequency needs—longer TTLs mean fewer refreshes, but shorter TTLs keep your cache more up-to-date.

  • Configure Virtual Repository Index Refresh
    For your virtual repository, ensure that the index refresh interval is set to a reasonable value. This ensures the combined index (from proxy + private repos) is periodically updated, even if individual proxy cache entries haven't expired yet.

  • Force pip to Bypass Local Cache (Quick Workaround)
    While not a long-term fix, running pip install --no-cache-dir -i https://myartifactory.net/api/pypi/virt/simple requests can force pip to ignore its local cache and re-query Artifactory, which may help if the issue is partially due to pip's local caching.

  • Verify Artifactory Proxy Configuration
    Double-check that your proxy repository has the correct upstream PyPI URL set, and that Artifactory has network access to reach it. If there's a connectivity issue, Artifactory can't refresh the cache even when triggered.

内容的提问来源于stack exchange,提问作者VanesBee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:35:16