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: have SimpleHTTPServer return last-modified headers
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: aaronsw, georg.brandl, jimjjewett
Priority: normal Keywords: patch

Created on 2006-01-28 19:24 by aaronsw, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
lastmodified.patch aaronsw, 2006-01-28 19:24 patch for last-modified header
Messages (5)
msg49421 - (view) Author: Aaron Swartz (aaronsw) Date: 2006-01-28 19:24
This patch modifies the SimpleHTTPServer to serve Last-Modified headers 
with its responses, which allows browsers to cache the result, preventing 
annoying reloads of image files every time you view a page, and so on.

Fixes 1417554.
msg49422 - (view) Author: Jim Jewett (jimjjewett) Date: 2006-02-01 16:32
Logged In: YES 
user_id=764593

If the server doesn't handle the If-Modified-Since header on 
requests, does this really help much?  (I suppose it does 
give browsers something to use as a heuristic.)

But adding that to Simple doesn't really make sense.  Adding 
it to BaseHTTPServer might.
msg49423 - (view) Author: Aaron Swartz (aaronsw) Date: 2006-02-01 18:04
Logged In: YES 
user_id=122141

Yes, it does help. RFC 2616 (HTTP/1.1 spec) says "HTTP caches typically 
assign heuristic expiration times, employing algorithms that use other header 
values (such as the Last-Modified time) to estimate a plausible expiration 
time" and indeed major browsers and caches actually do this.

Why doesn't it make sense to add this to SimpleHTTPServer? 
SimpleHTTPServer serves files from disk; this patch grabs the last-modified 
time for those files. It certainly wouldn't fit in BaseHTTP -- how would it know 
what the Last-Modified time would be?
msg49424 - (view) Author: Jim Jewett (jimjjewett) Date: 2006-02-02 14:09
Logged In: YES 
user_id=764593

Sorry,  I wasn't clear enough.  

Adding the Last-Modified to responses created by 
SimpleServer makes perfect sense.

I had been (wrongly) thinking it was only useful in 
conjunction with a possible "304 Not Modified" response.  
Adding the 304 logic to a "simple" server may not fit, but 
adding it to BaseServer (and calling it from SimpleServer, 
which has the file's timestamp) would be reasonable.
msg49425 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-02-17 13:35
Logged In: YES 
user_id=1188172

Thanks, I committed a similar patch (your date handling was
suboptimal).
History
Date User Action Args
2022-04-11 14:56:15adminsetgithub: 42846
2006-01-28 19:24:45aaronswcreate