如何获得Apache服务GZIP文件



前端:角度后端:PHP服务器:Apache

  1. 使用webpack插件(bundle.js.gz(
  2. 压缩文件
  3. 运行,但我会遇到错误。uck offult的语法:无效或意外的令牌捆绑包:1

  4. 状态代码为200,标题看起来像

    接受编码:gzip,deflate,br

我想念什么?

您想做的是提供预压缩内容。(bundle.js.gz(将以下部分添加到您的conf和reload。

<IfModule mod_headers.c>
    # Serve gzip compressed CSS and JS files if they exist
    # and the client accepts gzip.
    RewriteCond "%{HTTP:Accept-encoding}" "gzip"
    RewriteCond "%{REQUEST_FILENAME}.gz" -s
    RewriteRule "^(.*).(css|js)"         "$1.$2.gz" [QSA]
    # Serve correct content types, and prevent mod_deflate double gzip.
    RewriteRule ".css.gz$" "-" [T=text/css,E=no-gzip:1]
    RewriteRule ".js.gz$"  "-" [T=text/javascript,E=no-gzip:1]
    <FilesMatch "(.js.gz|.css.gz)$">
      # Serve correct encoding type.
      Header append Content-Encoding gzip
      # Force proxies to cache gzipped &
      # non-gzipped css/js files separately.
      Header append Vary Accept-Encoding
    </FilesMatch>
</IfModule>

最新更新