--- moinmoin-installed\Lib\site-packages\MoinMoin\Copy of request.py	2006-07-25 15:57:22.373580500 +0200
+++ moinmoin-installed\Lib\site-packages\MoinMoin\request.py	2006-07-25 16:09:05.515236400 +0200
@@ -67,6 +67,7 @@
 
     # Defaults (used by sub classes)
     http_accept_language = 'en'
+    if_modified_since = 0
     server_name = 'localhost'
     server_port = '80'
 
@@ -1400,6 +1401,7 @@
             
             # Copy headers
             self.http_accept_language = self.twistd.getHeader('Accept-Language')
+            self.if_modified_since = self.twistd.getHeader('If-Modified-Since')
             self.saved_cookie = self.twistd.getHeader('Cookie')
             self.http_user_agent = self.twistd.getHeader('User-Agent')
             
@@ -1627,6 +1629,8 @@
             # Copy headers
             self.http_accept_language = (sa.headers.getheader('accept-language') 
                                          or self.http_accept_language)
+            self.if_modified_since = (sa.headers.getheader('If-Modified-Since') 
+                                      or self.if_modified_since)
             self.http_user_agent = sa.headers.getheader('user-agent', '')            
             co = filter(None, sa.headers.getheaders('cookie'))
             self.saved_cookie = ', '.join(co) or ''
--- moinmoin-installed\Lib\site-packages\MoinMoin\action\Copy of AttachFile.py	2006-05-11 18:24:00.000000000 +0200
+++ moinmoin-installed\Lib\site-packages\MoinMoin\action\AttachFile.py	2006-07-27 16:18:00.419076800 +0200
@@ -30,6 +30,9 @@
 from MoinMoin import config, user, util, wikiutil, packages
 from MoinMoin.Page import Page
 from MoinMoin.util import MoinMoinNoFooter, filesys
+from MoinMoin.util import timefuncs
+import time
+import email.Utils
 
 action_name = __name__.split('.')[-1]
 
@@ -633,22 +636,53 @@
     filename, fpath = _access_file(pagename, request)
     if not filename: return # error msg already sent in _access_file
 
+    use_cached_version = False
+    filemtime = int(time.mktime(time.gmtime(os.path.getmtime(fpath)))) # in GMT
+    client_filemtime = -1
+    if hasattr(request, "if_modified_since") and request.if_modified_since != 0:
+        client_date = email.Utils.parsedate(request.if_modified_since)
+        if client_date:
+            client_filemtime = int(time.mktime(client_date))
+            if int(time.mktime(time.gmtime(filemtime))) == client_filemtime:
+                use_cached_version = True
+
     # get mimetype
     type, enc = mimetypes.guess_type(filename)
     if not type:
         type = "application/octet-stream"
 
-    # send header
-    request.http_headers([
-        "Content-Type: %s" % type,
-        "Content-Length: %d" % os.path.getsize(fpath),
-        # TODO: fix the encoding here, plain 8 bit is not allowed according to the RFCs
-        # There is no solution that is compatible to IE except stripping non-ascii chars
-        "Content-Disposition: attachment; filename=\"%s\"" % filename.encode(config.charset),
-    ])
 
-    # send data
-    shutil.copyfileobj(open(fpath, 'rb'), request, 8192)
+    if use_cached_version:
+        user_headers = []
+        for header in request.user_headers:
+            ignore_header = False
+            for h in ["Pragma:", "Expires:", "Cache-Control:"]:
+                if header.lower().startswith(h.lower()):
+                    ignore_header = True
+                    continue
+            if not ignore_header:
+                user_headers.append(header)
+        request.user_headers = user_headers
+        
+        # send header
+        request.http_headers([
+            "Content-Type: %s" % type,
+            "Content-Length: 0",
+            "Last-Modified: " + timefuncs.formathttpdate(filemtime),
+        ])
+        request.setResponseCode(304)
+    else:
+        # send header
+        request.http_headers([
+            "Content-Type: %s" % type,
+            "Content-Length: %d" % os.path.getsize(fpath),
+            # TODO: fix the encoding here, plain 8 bit is not allowed according to the RFCs
+            # There is no solution that is compatible to IE except stripping non-ascii chars
+            "Content-Disposition: attachment; filename=\"%s\"" % filename.encode(config.charset),
+            "Last-Modified: " + timefuncs.formathttpdate(filemtime),
+        ])
+        # send data
+        shutil.copyfileobj(open(fpath, 'rb'), request, 8192)
 
     raise MoinMoinNoFooter
 
