-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
404 returned if only compressed file exists #8182
Comments
@Dreamsorcerer and @bdraco I'm looking at how to fix this but could use some guidance. I basically see two possible routes:
Both approaches would make the assumption that the After hours of reading code, my gut says the 1st is the right way, but everything going on in the middle of those methods is still very much a black box to me. Thoughts? Are there downstream, user, performance, etc. effects here I'm missing? |
From your comment, its not clear if passing the stat result to The |
I guess strictly speaking it would not be "required", but without it you'd have to repeat the blocking Although given #8013, I wonder if the 2nd is the better approach so that the existence check and opening are in the same method?
Yeah I noticed that override. No argument on running the file system calls in an executor as I'd certainly fix that either way. Is that caching really giving much benefit though? Really you'd want to cache the |
Keep in mind that many users will have multiple clients hitting the same files so the caching prevents a thundering herd of executor jobs when HA restarts |
Will need to think some more on case 2 when everything isn’t so chaotic |
😕 But wouldn't that only occur if all those clients simultaneously deleted their cache and pressed F5 like a home grown DOS attack?
👍🏻 I think it scares me because I presume there is a good reason for checking permission and existence outside of |
What you are saying makes sense and I’m probably misremembering the cause but I do remember the caching solved a thundering herd issue.
|
Okay I think I figured this out, so anyone correct me if I'm off... The request The difference is that |
Actually, it is not documented on the website at all. Looks like docs were added to the master branch in #3991 that still exist, but those never made it to the 3.9 branch so are not live. |
Ah, that longs predates my backport label checks, so appears to have been missed. |
I'm going to leave this one with bdraco to decide what should be done. As far as I understand, StaticResource is only related to the static() setup, which we tell users not to use in production anyway, so I don't really care about performance or anything here personally. |
@Dreamsorcerer Right now, |
Right, I guess if it has an explicit path, then it suggests to me a developer mistake that should be fixed. In which case, maybe it's not worth doing a 404 and dropping the stat calls? |
I think there's a reasonable argument to be made for dropping them, but it would be a breaking change as it would then need to be passed by the user. It's used heavily in I don't know what the right approach is for v4.0, but putting my semver hat on for 3.10, what about something like:
|
Addendum to this issue: the entire exception handling structure in Strict isn't really needed and not desirable in order to fix this issue, so I'm working on cleaning that up and running the IO stuff in an executor. |
Is your feature request related to a problem?
Currently, the
StaticResource
handler immediately returns a 404 status if the requested file is not on disk:elif filepath.is_file():
. This is done before the response class checks for compressed versions of the file, making it impossible to store only compressed versions of static resources in order to conserve disk space.Furthermore, this is an extra unnecessary call for a file system operation that should be eliminated to gain performance. The file response class already gets a
stat
of the file in the executor to get things like the content length.Describe the solution you'd like
Accept-Encoding
header, regardless of uncompressed existence.is_file()
check.Describe alternatives you've considered
Only solution is to make sure uncompressed files always exist.
Related component
Server
Additional context
Technically, I think serving a 404 when a representation with a supported content coding exists is a violation of RFC 9110.
Code of Conduct
The text was updated successfully, but these errors were encountered: