vsivsi / meteor-file-collection

Extends Meteor Collections to handle file data using MongoDB gridFS.
http://atmospherejs.com/vsivsi/file-collection
Other
159 stars 37 forks source link

Respect If-Modified-Since in http_access_server.coffee #108

Closed edemaine closed 8 years ago

edemaine commented 8 years ago

Currently, http_access_server.coffee sends the requested file independent of any conditionals sent in the HTTP headers (see https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). A particularly useful header to respect would be If-Modified-Since to prevent resending files that haven't changed.

As I understand it, the modification to get would be something like this (between setting headers and checking for range header):

if Date.parse(req.headers['if-modified-since']) >= req.gridFS.uploadDate.getTime()
   res.writeHead 304, headers
   res.end()
   return

I haven't tested yet, though, hence no pull request. Let me know if you'd rather that.

vsivsi commented 8 years ago

Good idea. If you put together a solid PR (with passing tests for the new feature, including gracefully handling invalid/malformed headers, etc) I'll merge and release within a day or two. Otherwise it will probably take me weeks to get around to doin something like this myself right now.

edemaine commented 8 years ago

Cool, thanks for the quick response! I'll work on such a pull request.

vsivsi commented 8 years ago

Closing this to concentrate any remaining discussion on the open PR