You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While I don't believe a framework at this level should be sending Expires headers, there is no reason it can't implement 304 support using either Etags or LastModified headers (or maybe even both).
Yes, I agree with you here. Improved support for HTTP caching is something that I intend to add soon to strata, not just in the file middleware but in other places as well.
304 isn't really caching. It's just a conditional request. I don't think putting caching at the framework level is a good idea since proper caching is so application logic specific.
Also, when I was working on connect, I too tried to handle caching and 304 as a standalone middleware, but in the end decided that was a bad approach. There is too much leaky abstraction and 304 can be handled much better inside the file middleware. It's already statting the file and already has the request headers. It only needs to check if the stat matched the conditional request and skip the body and send 304. This is very simple and easy to get right. It makes sites much faster even if they don't use any caching at all.
Good point. I appreciate you sharing your previous experience, and I tend to agree that the file middleware should be handling this responsibility. I haven't looked into the spec for the Etag and Last-Modified headers lately, but I'll try and get some time to look into it and follow the implementation you suggest soon.
While I don't believe a framework at this level should be sending Expires headers, there is no reason it can't implement 304 support using either Etags or LastModified headers (or maybe even both).
For etags, I would suggest something fast like https://github.com/c9/vfs/blob/master/local/localfs.js#L30-32 instead of hashing the content of the file or some other expensive operation.
The text was updated successfully, but these errors were encountered: