Alec Flett wrote: > Hey - > We've been using StaticURLParser to serve up our static files (under > pylons) but we've run into a few issues. > > One of the biggest is the ETags header. The problem is that we're > deploying across a bunch of machines in a cluster, and static files get > pulled out of SVN, which timestamps the files with the date as it's > checked out. This means that each machine has a different etag for each > file, because each file has a different date. > > Now one option is to fix our deployment to go re-touch the files after > they've been checked out, to match their timestamps in svn. > > But another option is to do md5-based etagging... so it's really the > contents of the file, not the date that happens to be on disk. > > This brings up a few problems with StaticURLParser/fileapp: > - Headers are not really configurable. Frankly a last ditch effort would > be to stop including the ETag header altogether, but Paste makes this > extraordinarily hard - I can monkeypatch it but it's really not pretty. > I can make middleware, but it seems like overkill to write middleware > just to remove a header > - Really, if the ETag was the MD5 of the file, then the etag would be > consistent across the cluster. This technique is described here: > http://dev.aol.com/implementing-atom-publishing-protocol-python-wsgi > <http://dev.aol.com/implementing-atom-publishing-protocol-python-wsgi> > > The trick with doing MD5 is how/when do you calculate the MD5 hash to > compare it to If-None-Match? Clearly MD5 hashing is more expensive than > just stat()ing a file. I can think of a few possibilities:
I think you should subclass FileApp and override calculate_etag. You could look for a .md5 file, make sure its mtime was newer than the file it was for, generate the file if it wasn't present, and return the contents of that md5 file. You can subclass StaticURLParser and override make_app to use your FileApp subclass. -- Ian Bicking : [EMAIL PROTECTED] : http://blog.ianbicking.org : Write code, do good : http://topp.openplans.org/careers _______________________________________________ Paste-users mailing list [email protected] http://webwareforpython.org/cgi-bin/mailman/listinfo/paste-users
