This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: SimpleHTTPRequestHandler should support browser cache
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: quentel, serhiy.storchaka, v+python, vstinner
Priority: normal Keywords:

Created on 2017-02-25 21:20 by quentel, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 298 merged python-dev, 2017-02-25 21:25
Messages (7)
msg288581 - (view) Author: Pierre Quentel (quentel) * Date: 2017-02-25 21:20
SimpleHTTPServer send a Last-Modified response header, but doesn't take into account the If-Modified-Since header if it was sent by the user agent. 

If a url matches a file and this file was not modified after the value of the If-Modified-Since header, the server should return HTTP status 304 (Not Modified).
msg291028 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-04-02 10:26
New changeset 351adda54bed3afbbf6db7725699679e68722d7d by Serhiy Storchaka (Pierre Quentel) in branch 'master':
bpo-29654 : Support If-Modified-Since HTTP header (browser cache) (#298)
https://github.com/python/cpython/commit/351adda54bed3afbbf6db7725699679e68722d7d
msg291029 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-04-02 10:27
Thank you for your contribution Pierre.
msg299405 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-07-28 16:19
FYI there was a race condition, impacting Windows. I just fixed it: bpo-31066, commit 28ce07ae9e34c70eea6b52515c7e00001cefd41e.
msg299472 - (view) Author: Pierre Quentel (quentel) * Date: 2017-07-29 14:43
Thanks for telling me. I must have run the test hundreds of times now, on a
Windows 7 PC, and this bug never occured.

Just for my information, why do you add temp.flush() in the "with" block ?
I thought the context manager took care of this.

2017-07-28 18:19 GMT+02:00 STINNER Victor <report@bugs.python.org>:

>
> STINNER Victor added the comment:
>
> FYI there was a race condition, impacting Windows. I just fixed it:
> bpo-31066, commit 28ce07ae9e34c70eea6b52515c7e00001cefd41e.
>
> ----------
> nosy: +haypo
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue29654>
> _______________________________________
>
msg299543 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-07-31 08:56
Thank you Victor!

I suppose temp.flush() is a remnant of other (unsuccessful) attempt to fix a race condition.
msg299588 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-07-31 22:35
I suppose temp.flush() is a remnant of other (unsuccessful) attempt to fix
a race condition.

I didn't try only with .flush(). I prefer to explicitly .flush(), just in
case :-) Using correctly a file system is complex because of all layers of
caching.
History
Date User Action Args
2022-04-11 14:58:43adminsetgithub: 73840
2017-07-31 22:35:58vstinnersetmessages: + msg299588
2017-07-31 08:56:26serhiy.storchakasetmessages: + msg299543
2017-07-29 14:43:29quentelsetmessages: + msg299472
2017-07-28 16:19:47vstinnersetnosy: + vstinner
messages: + msg299405
2017-04-02 10:27:13serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg291029

stage: resolved
2017-04-02 10:26:14serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg291028
2017-03-03 23:07:04v+pythonsetnosy: + v+python
2017-02-25 21:25:33python-devsetpull_requests: + pull_request264
2017-02-25 21:20:35quentelcreate