Description
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
- Return the compressed file when permitted by the
Accept-Encodingheader, regardless of uncompressed existence. - Return a 406 if the compression is not supported by the client, or permit dynamic decompression.
- Eliminate the extra
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
- I agree to follow the aio-libs Code of Conduct