petersirka / node-filestorage

Storage for storing uploaded files in node.js
MIT License
72 stars 12 forks source link

Allow more control over caching #15

Closed oliversalzburg closed 8 years ago

oliversalzburg commented 8 years ago

When I .pipe() a file into an Express response object, the Cache-Control header will be set to public, with no max-age part. Also, the Expires header is set for 2 months.

In some cases, this might be undesirable. An option to control this behavior would be much appreciated :)

petersirka commented 8 years ago

Hi @oliversalzburg, I'll fix it.

petersirka commented 8 years ago

Please download this module from GitHub and try the cache. I have fixed it. I'm waiting for your feedback

oliversalzburg commented 8 years ago

@petersirka Thanks a lot for the quick change! However, what I had in mind was to be able to specify for how long the file should be cached.

We're using node-filestorage to serve user avatars. They are currently cached for a very long time in the browser cache. Some caching is definitely desired, but we would prefer to set a max-age of like 5 minutes. So that users will see updated avatars in a reasonable time.

oliversalzburg commented 8 years ago

@petersirka We've combined your fix with a changed approach on our side and it's working great now. If you would make an npm release for 1.4.0 that would be awesome.

Thanks for your work :)

petersirka commented 8 years ago

Hi @oliversalzburg, so can I publish the module into the NPM? Or do you need some change? If yes, can you create a pull request? Thanks

oliversalzburg commented 8 years ago

@petersirka Seems to work fine. We're currently deploying your latest changes to our development servers for final testing. But a release to NPM would be great for us :)

petersirka commented 8 years ago

Great. I have publish it into the NPM. Thanks.