Skip to content

Commit dcc3c16

Browse files
committed
Only revalidate /simple/ pages instead of caching for 10 minutes
1 parent 7620b37 commit dcc3c16

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

news/5670.bugfix

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Always revalidate cached simple API pages instead of blindly caching them for up to 10
2+
minutes.

src/pip/_internal/index.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,20 @@ def get_page(cls, link, skip_archives=True, session=None):
783783
url,
784784
headers={
785785
"Accept": "text/html",
786-
"Cache-Control": "max-age=600",
786+
# We don't want to blindly returned cached data for
787+
# /simple/, because authors generally expecting that
788+
# twine upload && pip install will function, but if
789+
# they've done a pip install in the last ~10 minutes
790+
# it won't. Thus by setting this to zero we will not
791+
# blindly use any cached data, however the benefit of
792+
# using max-age=0 instead of no-cache, is that we will
793+
# still support conditional requests, so we will still
794+
# minimize traffic sent in cases where the page hasn't
795+
# changed at all, we will just always incur the round
796+
# trip for the conditional GET now instead of only
797+
# once per 10 minutes.
798+
# For more information, please see pypa/pip#5670.
799+
"Cache-Control": "max-age=0",
787800
},
788801
)
789802
resp.raise_for_status()

0 commit comments

Comments
 (0)