-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
File server missing Vary on 206, 304 #5849
Comments
Hm, interesting. I didn't know that (guess I didn't read the spec.) I'm currently attending to a hospital stay and will be delayed with my work a bit. Is there anyone who would like to pick this up? |
@mholt I can try, but I'm a Golang newbie and will probably need a bit of guidance, it that's not too annoying? |
@dkarlovi No that should be fine! I am a bit swamped lately (as you can see I'm behind on issues and PRs) -- with a hospital stay I'm attending to, but I will do my best to offer feedback. If it ends up being too much, it's OK to let someone else take it on. But you're certainly welcome! |
@mholt thanks, I'll try to take a stab at it, it's no rush since nobody complained until now. 😆 Hope the hospital sees the back of you ASAP, all the best with that, take care. |
I think this might be pretty tricky to solve, because Caddy's |
I could also take a stab at this since I've lately been digging into |
@fortum-vaanavil TBH since I've read @francislavoie comment about it being non-trivial, I got discouraged about being able to do it so please feel free to take the lead here, thank you! |
Sorry 😓 didn't mean to be discouraging, just wanted to manage expectations. PRs definitely welcome. But make sure to take care to not break abstractions ( |
No problems, I didn't interpret it as hostile, on the contrary: you've warned this might not be the best place for me to try getting into Go (and Caddy's codebase) so I'll find some other place to contribute, don't worry. 👍 Thanks! |
@dkarlovi Can you provide a little more information about the kinds of requests and responses that have these validation errors? Preferably a minimal config and some That said, I believe I have a commit that should fix your initial report if I guessed right. I did my best to reproduce a likely scenario locally and verified that my browser was still able to use its cached values with the patched logic. Could you please try the latest on master to confirm? Thanks! |
@mholt Most warnings that REDbot reported as shown in here have been fixed (checked just now), except for the "Vary" one. |
Thanks for the update, but can you provide more details? Otherwise I'm just guessing. What is a request and response that have the headers wrong? How can I reproduce these results? |
@mholt RedBot is OSS https://github.com/mnot/redbot you should be able to use it to lint against your local Caddy instance easily, I'm not sure if it provides a way to prepare copy/pastable curl requests. If not, maybe a feature suggestion on the repo? About your question, IMO the fix should be that 304 keeps the same |
I'm not sure about the ETag one myself either, will check in a bit. I'll provide proper examples in a bit. |
Ahh thanks, didn't realize I could run it locally. I'll try it soon. Let me know if you have more info in the meantime. |
I'm having trouble using Redbot locally (getting "Access Error" when I try on localhost -- I guess it doesn't allow localhost access?? I'm not sure how to override that), so yeah, until I can figure that out, any more info you have would be great. |
@mholt are you running it from Docker? RedBot running in Docker wouldn't have access to Caddy running directly on your host. 🤔 I don't remember having any issues running it locally before, but maybe something changed in the meantime. I don't see why it would though because RedBot is itself just doing basically specific Curl requests and asserting against expectations, there isn't really anything inherently wrong with localhost for it to not work. |
No, I used |
@mholt the Makefile has a cli command which uses the config.txt as an argument |
Oh -- the config gets compiled in 😮 Hm, that only seems to be for the server. I just use the CLI... |
I'll need to check, will get back to you. |
@mholt Both issues are present. My screenshots are on the latest commit @ master. |
Oh sorry, I pinged the wrong person. Thanks @JeDaYoshi 😅 How are you testing locally with REDbot? |
I'm not testing locally. I am using the hosted instance against a Caddy instance on a VPS. |
No it doesn't, the Makefile is used as a "tooling shortcut" (a Makefile is just a way to declare a bunch of bash scripts, in a really terrible awful garbage archaic format 😂 ). The python script takes |
I see; I think I am using the CLI though, not the server daemon. |
@JeDaYoshi @dkarlovi Ok, I got the daemon running locally, security risks and all 😁 I think I was able to fix at least some of the Vary notices, please check with d00824f. @JeDaYoshi I'm still trying to find a time when the "response status is different when content negotiation happens" notice appears, but now that I've fixed the Vary it might actually fix that too. Can you please |
I'm pretty sure that's allowed. It simplifies processing at least :)
Ah, let me try that next. That's new information. |
Yeah, but shouldn't
or..
(admittedly, I'm not sure why would you define Accept-Encoding in a header yourself. I'm just asking because the function exists.)
My apologies - thought I mentioned it, and just noticed a bit ago I didn't! |
No, that function specifically prevents repeating a header name in the value of the Vary header. i.e.:
is prevented. Semantically, it doesn't matter how many times a header field like this appears. |
@JeDaYoshi I'll need more information as I can't reproduce it with REDbot. Please provide your full (but minimalistic) config as well as the request(s) and/or REDbot config that yields those results. |
My apologies for not getting back to you about this, @mholt. Got busy for a while. After thinking about it for a bit, I realised now what is the issue: the This is not a situation you run into if you're compressing the requests real-time with But let's do an example:
And in
This is where the issue runs into. Those files are not using an ETag file, but instead uses caddy/modules/caddyhttp/fileserver/staticfiles.go Lines 669 to 680 in 87c7127
The ETag headers don't match between requests:
And that's what REDbot complains about when sending a |
Sorry for the double-ping @mholt, just wanting to check if my response wasn't dismissed accidentally :) |
Yeah I saw it, sorry, just been busy working on the 2.8 release |
@JeDaYoshi Finally having a moment to investigate what you wrote... Are you sure that's correct? I am probably misunderstanding. I set up a test file with 3 precompressed variants like what you have, and made them all have the same Etag for every Accept-Encoding. Then redbot tells me:
When I change it back to how it is now (different Etags for each representation), the error goes away and I get all green/black statuses. |
I'm checking my caching headers for assets served by file server. It all works as expected, but RedBot claims it should be adding
Vary
when serving 206, 304.I've checked Caddy site itself that it's not some misconfiguration on my end, but it doesn't seem to be, the case there seems even worse:
https://redbot.org/?uri=https://caddyserver.com/resources/css/docs.css?v=dfd5278
It seems the Vary needs to be sent in both cases.
The text was updated successfully, but these errors were encountered: