messagecao
V2EX  ›  Node.js

请教: nuxt 如何配置 gzip?

  •  
  •   messagecao · Jun 28, 2018 · 8316 views
    This topic created in 2875 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
        1
    wxsm  
       Jun 28, 2018   ❤️ 1
    一般都是用 nginx 等代理来做 gzip 压缩,没有必要在 nuxt 中配置。
    e8c47a0d
        2
    e8c47a0d  
       Aug 10, 2018
    gzip 指的是,对 http 的 response 的 body 进行压缩,也就是把你的 css、js、html 这些重复率多的文本文件压缩后,加上 content-encoding: gzip 这个 header 传给你的客户端。如果你有用 nginx 做反向代理的话,建议关掉 gzip。因为 nginx 会自动帮你压缩,而且相比 js 来压缩,nginx 更快。
    e8c47a0d
        3
    e8c47a0d  
       Aug 10, 2018   ❤️ 2
    在 nuxt 中开启 gzip 的话会对你的服务器产生一点负担。
    hanzichi
        4
    hanzichi  
       Jan 19, 2020
    所以怎么关掉呢,有找到方法吗?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3185 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 14:28 · PVG 22:28 · LAX 07:28 · JFK 10:28
    ♥ Do have faith in what you're doing.