Skip to content

Commit 355e068

Browse files
committed
fix: Send vary header for if-modified-since conditional returning 304
Send the vary: accept-encoding header if a conditional if-modified-since requests results in a 304 not modified response.
1 parent e79b4d2 commit 355e068

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ Fixed:
166166
testing. (John Rouillard)
167167
- make If-None-Match work for static file (@@file) case. Found by
168168
Redbot testing (John Rouillard)
169+
- Send vary: accept-encoding for if-modified-since conditional
170+
requests where the file is not modified. (John Rouillard)
169171

170172
Features:
171173

roundup/cgi/client.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,10 +1999,15 @@ def _serve_file(self, lmt, mime_type, content=None, filename=None):
19991999
ims = email.utils.parsedate(ims)[:6]
20002000
lmtt = time.gmtime(lmt)[:6]
20012001
if lmtt <= ims:
2002-
if (self.determine_content_encoding()):
2003-
# set vary header as though we were returning 200
2004-
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Vary
2005-
self.setVary("Accept-Encoding")
2002+
# because we can compress, always set Accept-Encoding
2003+
# value. Otherwise caches can serve up the wrong info
2004+
# if their cached copy has no compression.
2005+
self.setVary("Accept-Encoding")
2006+
'''
2007+
to solve issue2551356 I may need to determine
2008+
the content encoding.
2009+
if (self.determine_content_encoding()):
2010+
'''
20062011
raise NotModified
20072012

20082013
# don't set until we are sure we are sending a response body.

0 commit comments

Comments
 (0)