[Patches] [ python-Patches-1417555 ] have SimpleHTTPServer return last-modified headers

SourceForge.net noreply at sourceforge.net
Fri Feb 17 14:35:45 CET 2006


Patches item #1417555, was opened at 2006-01-28 20:24
Message generated for change (Comment added) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1417555&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.4
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Aaron Swartz (aaronsw)
Assigned to: Nobody/Anonymous (nobody)
Summary: have SimpleHTTPServer return last-modified headers

Initial Comment:
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.

----------------------------------------------------------------------

>Comment By: Georg Brandl (birkenfeld)
Date: 2006-02-17 14:35

Message:
Logged In: YES 
user_id=1188172

Thanks, I committed a similar patch (your date handling was
suboptimal).

----------------------------------------------------------------------

Comment By: Jim Jewett (jimjjewett)
Date: 2006-02-02 15:09

Message:
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.


----------------------------------------------------------------------

Comment By: Aaron Swartz (aaronsw)
Date: 2006-02-01 19:04

Message:
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?

----------------------------------------------------------------------

Comment By: Jim Jewett (jimjjewett)
Date: 2006-02-01 17:32

Message:
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.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1417555&group_id=5470


More information about the Patches mailing list