Elixir Plug gzip 不适用于 png

Elixir Plug gzip not working for pngs

我有

plug Plug.Static,
  at: "/pros",
  from: :zipbooks,
  gzip: true,
  cache_control_for_etags: "public, max-age=604800",
  only: ~w(css assets fonts images js favicon.ico robots.txt)

和我的 js csssvg 文件正在使用 content-encoding:gzip 提供,但我的 png 文件以相同的方式提供,却没有。

这是一个 svg 示例及其压缩方式:

这是一个 png

您需要将 .png 添加到 gzippable_exts 配置中,如文档 here 中所述。

We can optionally determine which files should be gzipped by using the :gzippable_exts option in the config file:

config :phoenix, :gzippable_exts, ~w(.js .css)

压缩 png 文件没有意义,因为它们已经被压缩,这就是 default gzippable_exts 不包含它的原因。