Sitelet https://github.com/honojs/node-server/issues/360
Skip to content

Please document the COMPRESSIBLE_CONTENT_TYPE_REGEX-related behavior #360

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions