web/views/staticcontrollers.py
changeset 8323 fe60a77ae4a7
parent 8298 2a4bc6f75e9c
child 8325 7f2337d7937f
--- a/web/views/staticcontrollers.py	Tue Mar 20 18:25:06 2012 +0100
+++ b/web/views/staticcontrollers.py	Mon Mar 19 14:37:43 2012 +0100
@@ -67,6 +67,16 @@
             # the HTTP RFC recommands not going further than 1 year ahead
             expires = datetime.now() + timedelta(days=6*30)
             self._cw.set_header('Expires', generateDateTime(mktime(expires.timetuple())))
+
+        # XXX system call to os.stats could be cached once and for all in
+        # production mode (where static files are not expected to change)
+        #
+        # Note that: we do a osp.isdir + osp.isfile before and a potential
+        # os.read after. Improving this specific call will not help
+        #
+        # Real production environment should use dedicated static file serving.
+        self._cw.set_header('last-modified', generateDateTime(os.stat(path).st_mtime))
+        self._cw.validate_cache()
         # XXX elif uri.startswith('/https/'): uri = uri[6:]
         mimetype, encoding = mimetypes.guess_type(path)
         self._cw.set_content_type(mimetype, osp.basename(path), encoding)