Feature request: serve pre-compressed static files (`gzip_static`)

未关闭
#28 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
56/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
c

调研方向

首先跟踪 uhttpd 的静态文件请求路径,以及它对 Accept-Encoding 和 Content-Type 的处理。仅当接受 gzip 时才实现选择同名 .gz 文件,保留原始文件的类型,并验证未压缩文件的提供方式保持不变。

由索引模型根据 Issue 内容生成。

描述

Summary

Please consider adding static pre-compressed file serving to uhttpd: when a request for foo.css arrives with Accept-Encoding: gzip and a sibling file foo.css.gz exists on disk, serve the .gz bytes verbatim with Content-Encoding: gzip and the original file's Content-Type.

This is not on-the-fly (dynamic) compression. It simply hands back an already-compressed file that the developer/build system produced ahead of time. Request-time CPU cost is therefore lower than serving the uncompressed file (fewer bytes pushed through the network stack), not higher — which keeps it in line with uhttpd's goal of being a minimal, low-overhead server for constrained devices.

Use case

I'm developing a modern LuCI theme. It's built with Tailwind CSS, which — even after tree-shaking and minification — emits a fairly large stylesheet because of the volume of utility classes and generated custom properties the design relies on. The result is highly repetitive text, which is close to the ideal case for gzip.

Measured on my theme's production build:

File Raw (bytes) gzip -9 (bytes) Saving
main.css 211,725 27,808 −87%
login.css 30,498 6,604 −78%
menu-aurora.js 17,348 4,604 −73%

Shipping the .gz sibling would cut the transfer size of these assets by roughly an order of magnitude, with no added request-time cost to the router.

主要语言
C
星标
39
派生
31
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

openwrt/uhttpd 的其他 Issue

查看 openwrt/uhttpd 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。