在Firebase Hosting上提供gzip压缩文件

klq*_*klq 8 firebase-hosting

我有兴趣使用Firebase Hosting提供gzipped html/css/js文件.我尝试在firebase.json中设置Content-Encoding标头,但在部署时出错.

据称,您可以设置的唯一标头包括:Cache-Control,Access-Control-Allow-Origin,X-UA兼容,X-Content-Type-Options,X-Frame-Options,X-XSS-Protection

有什么想法吗?

Seb*_*ist 25

默认情况下,Firebase Hosting已经压缩了所有文件.例如,这里是我在firebase上托管的css文件的响应头.注意Content-Encoding标题:

Accept-Ranges:bytes
Cache-Control:max-age=7178000
Connection:keep-alive
Content-Encoding:gzip
Content-Length:3483
Content-Type:text/css; charset=utf-8
Date:Sun, 10 Jan 2016 02:09:57 GMT
ETag:"4c94283e07340e9cc0237fc2a349c94d"
Last-Modified:Sun, 10 Jan 2016 00:10:31 GMT
Server:nginx
Strict-Transport-Security:max-age=31556926; includeSubDomains; preload
Vary:Accept-Encoding
Via:1.1 varnish
X-Cache:HIT
X-Cache-Hits:1
X-Powered-By:Express
X-Served-By:cache-lax1432-LAX
Run Code Online (Sandbox Code Playgroud)

  • 我不知道是否发生了变化,但我的 css 文件返回以下内容,没有内容编码: ```Accept-Ranges:bytes Cache-Control:max-age=31536000 Connection:keep-alive Content-Length:3360 Content -类型:文本/CSS;charset=utf-8 日期:2016 年 9 月 15 日星期四 00:56:13 GMT ETag:“83bab03bd7b4d7f01f03858b2c1e58a2” 上次修改时间:2016 年 9 月 14 日星期三 07:08:13 GMT 服务器:nginx Strict-Transport-Security:max-age =31556926;包括子域;预加载 Vary:Accept-Encoding Via:1.1 清漆 X-Cache:HIT X-Cache-Hits:1 X-Powered-By:Express X-Served-By:cache-sjc3135-SJC``` (3认同)