Skip to content

Commit

Permalink
Merge pull request #5791 from dstufft/zero-cache-time-simple
Browse files Browse the repository at this point in the history
Only revalidate /simple/ pages instead of caching for 10 minutes
  • Loading branch information
dstufft authored Sep 18, 2018
2 parents 7620b37 + dcc3c16 commit 6296766
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions news/5670.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Always revalidate cached simple API pages instead of blindly caching them for up to 10
minutes.
15 changes: 14 additions & 1 deletion src/pip/_internal/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,20 @@ def get_page(cls, link, skip_archives=True, session=None):
url,
headers={
"Accept": "text/html",
"Cache-Control": "max-age=600",
# We don't want to blindly returned cached data for
# /simple/, because authors generally expecting that
# twine upload && pip install will function, but if
# they've done a pip install in the last ~10 minutes
# it won't. Thus by setting this to zero we will not
# blindly use any cached data, however the benefit of
# using max-age=0 instead of no-cache, is that we will
# still support conditional requests, so we will still
# minimize traffic sent in cases where the page hasn't
# changed at all, we will just always incur the round
# trip for the conditional GET now instead of only
# once per 10 minutes.
# For more information, please see pypa/pip#5670.
"Cache-Control": "max-age=0",
},
)
resp.raise_for_status()
Expand Down

0 comments on commit 6296766

Please sign in to comment.