messagecao
V2EX  ›  Node.js

请教: nuxt 如何配置 gzip?

  •  
  •   messagecao · Jun 28, 2018 · 8762 views
    This topic created in 3054 days ago, the information mentioned may be changed or developed.
    看了官网,搜了谷歌,搜了百度,nuxt.config.js 中也配置了 performance 属性,但是打包后 js、css 之类的资源仍然没有压缩为.gz ,请教一下小伙伴们?需要怎么配置呢?
    4 replies  •  2020-01-19 16:28:10 +08:00
    wxsm
    wxsm
    Jun 28, 2018❤️1
    1
    一般都是用 nginx 等代理来做 gzip 压缩,没有必要在 nuxt 中配置。
    e8c47a0d
    e8c47a0d
    Aug 10, 2018
    2
    gzip 指的是,对 http 的 response 的 body 进行压缩,也就是把你的 css、js、html 这些重复率多的文本文件压缩后,加上 content-encoding: gzip 这个 header 传给你的客户端。如果你有用 nginx 做反向代理的话,建议关掉 gzip。因为 nginx 会自动帮你压缩,而且相比 js 来压缩,nginx 更快。
    e8c47a0d
    e8c47a0d
    Aug 10, 2018❤️2
    3
    在 nuxt 中开启 gzip 的话会对你的服务器产生一点负担。
    hanzichi
    hanzichi
    Jan 19, 2020
    4
    所以怎么关掉呢,有找到方法吗?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1664 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 74ms · UTC 14:59 · PVG 22:59 · LAX 06:59 · JFK 09:59
    ♥ Do have faith in what you're doing.