Skip to content

Please document the COMPRESSIBLE_CONTENT_TYPE_REGEX-related behavior #360

@mahmoud-moursy

Description

@mahmoud-moursy

In the serveStatic middleware, there exists a check for compressible content types (in the COMPRESSIBLE_CONTENT_TYPE_REGEX)... if this check fails, then the compressed version of a file will never be served, even IF there does exist a compressed variant of that file!

While experimenting with using compression for a large binary file in one of my web projects, I found after analysing the network requests that the large file was not being served as a compressed Brotli file like it should have been (thus wasting precious network bandwidth and user time)!

When I saw that other files, like the actual .html were being served compressed, I had a hunch something was awry in the serveStatic middleware. After peeking the source code, I found that my hunch was correct, and renaming file from .bin to .txt (although technically incorrect) made Hono start serving the compressed version of the large file!

Considering that this behaviour is undocumented and could lead to user confusion, I ask that you document this somewhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions