1

我们使用 GZIP 压缩从 NodeJS Express 服务器提供我们的 React 应用程序。

// app.js
app.get('*.js', (req, res, next) => {
  req.url = req.url + '.gz'; // eslint-disable-line
  res.set('Content-Encoding', 'gzip');
  next();
});

// webpack config
new CompressionPlugin({
  algorithm: 'gzip',
  test: /\.js$|\.css$|\.html$/,
  threshold: 10240,
  minRatio: 0.8,
}),

我们使用 Heroku 进行部署,使用 Cloudfare 作为反向代理。当我检查 Chrome DevTools 网络选项卡时,我看到请求是通过Brotli 压缩的

access-control-allow-credentials: ---
access-control-allow-headers: ---
access-control-allow-methods: ---
access-control-allow-origin: ---
access-control-expose-headers: ---
access-control-max-age: ---
cf-ray: ---
content-encoding: br
content-type: text/plain
date: Wed, 27 Feb 2019 22:46:29 GMT
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
status: 200
via: 1.1 vegur

有人知道这是否是 Cloudflare 方面的某种渐进增强功能,可将受支持客户端的压缩更新为brfrom ?gzip我看到我们可以通过Cloudflare 仪表板启用 Brotli,但我们还没有启用它。我也明白,如果资源已经被 gzip 压缩,Cloudflare 会尊重这一点。关于为什么压缩br而不是压缩的任何想法gzip

4

0 回答 0