-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supporting Last-Modified Header for StaticFiles #1219
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am generally in favor of this proposal, and I agree that it makes sense to add it as an opt-in to NamedFile
instead of unconditionally to File
.
dd566f5
to
381b584
Compare
@jebrosen, I addressed your comments and update the PR. |
74113c3
to
95c981d
Compare
381b584
to
962aa9e
Compare
Besides needed a rebase, what is the status of this? |
962aa9e
to
692f04e
Compare
@SergioBenitez, the PR was stuck due to incompatible APIs (see comments above). I updated the PR and pushed a new version that use the headers crate (suggested by @jebrosen). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM; I requested a few minor changes. The encoding/decoding is a little bit wonky, but I think that would best be resolved by implementing #1067 with the headers
crate.
692f04e
to
60f8133
Compare
60f8133
to
ca59e7e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me, with a small expansion to the docs.
I think this PR already satisfies my concerns from #1376 (review) by being opt-in via a new constructor. So my vote is for this PR, which also includes tests already.
27be497
to
9d1fe40
Compare
9d1fe40
to
efe0958
Compare
@SergioBenitez, did you have the chance to review this pull request? |
efe0958
to
5b48e99
Compare
5b48e99
to
d15a1d2
Compare
d15a1d2
to
59032f3
Compare
@SergioBenitez, @jebrosen do you have any idea why the build “Linux Debug (nightly)” after I rebased this PR? The error message seems unrelated to the changes in this PR. |
Likely a change in how diagnostics are rendered. I'll take a close look now. |
The unit tests should now pass. |
This commit adds basic support of Last-Modified and If-Modified-Since headers in order to enable HTTP caching while serving static files.
59032f3
to
e9aea56
Compare
@SergioBenitez, thanks. It works again. |
@@ -133,6 +133,12 @@ impl Options { | |||
/// that would be served is a directory. | |||
pub const NormalizeDirs: Options = Options(0b0100); | |||
|
|||
/// `Options` enabling caching based on the `Last-Modified` header. When | |||
/// this is enabled, the [`StaticFiles`] handler will at the `Last-Modified` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// this is enabled, the [`StaticFiles`] handler will at the `Last-Modified` | |
/// this is enabled, the [`StaticFiles`] handler will add the `Last-Modified` |
@@ -133,6 +133,12 @@ impl Options { | |||
/// that would be served is a directory. | |||
pub const NormalizeDirs: Options = Options(0b0100); | |||
|
|||
/// `Options` enabling caching based on the `Last-Modified` header. When | |||
/// this is enabled, the [`StaticFiles`] handler will at the `Last-Modified` | |||
/// header baesd on the modification datetime of the files in the served |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// header baesd on the modification datetime of the files in the served | |
/// header based on the modification datetime of the files in the served |
I don't think the API or implementation here are ones that I'm in favor of. Specifically:
Before revisting an implementation for this and #95 in general, I would like to agree on an API design and implementation strategy that has none of these drawbacks. Until then, I am closing this pull request. |
This commit adds basic support of Last-Modified and If-Modified-Since headers in order to enable HTTP caching while serving static files. #95