-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Expose API to set cache-control and other headers #58
Comments
I did some printf debugging and found that it is apparently exercising the code to set the ETag header properly, so I'm not sure what's happening there. I tried without any middlewares and without I'll try a minimal repro tomorrow. |
I noticed the example works just fine, so it must be something in my project's setup. I'll keep debugging it. |
Hey @steadygaze Check your Browser settings, I often activate "No cache" option in Firefox during dev. In curl you need -v option. Or maybe it is really something very specific for your configuration. Anyway, thank you for reporting! |
Yeah, thanks for the suggestions; I discovered a a day or two later that it was actually just one of my custom routes. I was under the mistaken impression that one of my routes was managed by this crate. (So, it was my own stupidity/forgetfulness 🤦😆.) What I was trying to do is to run If it's not considered too trivial, I can probably contribute what I did to the examples repo when I get the chance. Related to being able to set cache-control headers, I don't really need the feature that badly right now to be honest, but when I get around to it, I'd happily contribute it. |
Hi, I found this package useful; thanks for maintaining it!
I was looking at the code in this crate, and I noticed that it should be setting ETags, but they aren't showing up at all when I look at the headers in the browser devtools or curl. This is despite the content-type being detected and set correctly. Example:This seems like a bug to me. Looking at the code in respond_to, I don't see how it could both set the content-type but not the etag, so I'm not sure how to fix it.EDIT: I think it's related to my project setup somehow; I'll keep debugging it.Additionally, I was looking through the API docs and I realized there is no way to set the headers that are sent back, specifically the cache-control headers, which are complimentary to etags.
I was looking at the code and it seemed like somewhere in respond_to would be the right place to set custom headers. Probably the simplest way to implement this is to take a static list of headers to inject, but it would probably be more powerful to add an API (to
ResourceFiles
) that takes a lambda that is given the file and the in-progressHttpResponseBuilder
and can do whatever it wants.The text was updated successfully, but these errors were encountered: