[英]How to get apache serve gzip files?
Front end: Angular Back end: PHP Server: Apache前端:Angular 后端:PHP 服务器:Apache
Run but I get errors.运行,但出现错误。 Uncaught SyntaxError: Invalid or unexpected token bundle.js.gz:1未捕获的语法错误:无效或意外的令牌 bundle.js.gz:1
Status code is 200 and Headers looks like状态代码是 200,标题看起来像
Accept-Encoding: gzip, deflate, br接受编码:gzip、deflate、br
What do I miss?我想念什么?
What you want to do is serve pre-compressed content.您要做的是提供预压缩的内容。 (bundle.js.gz) Add the following part to your site.conf and reload. (bundle.js.gz) 将以下部分添加到您的 site.conf 并重新加载。
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.