Apache 使用angular 4、litespeed cpanel在响应头中没有gzip压缩

Apache 使用angular 4、litespeed cpanel在响应头中没有gzip压缩,apache,angular,.htaccess,gzip,Apache,Angular,.htaccess,Gzip,我通过angular cli--angular 4(ng build--prod--bo)构建了一个应用程序,并上传到了 我尝试了通过.htaccess启用gzip压缩的所有可能的代码,但都没有成功 以下是迄今为止我的.htaccess: <IfModule mod_deflate.c> # Compress HTML, CSS, JavaScript, Text, XML and fonts AddOutputFilterByType DEFLATE application

我通过angular cli--angular 4(ng build--prod--bo)构建了一个应用程序,并上传到了

我尝试了通过.htaccess启用gzip压缩的所有可能的代码,但都没有成功

以下是迄今为止我的.htaccess:

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>



## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##





RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]

# If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html
和请求头:

:authority:armen.jahanbani.ir
:method:GET
:path:/main.17622fc4e9e5f19aa68d.bundle.js
:scheme:https
accept:*/*
accept-encoding:gzip, deflate, br
accept-language:en-US,en;q=0.8,fa;q=0.6
alexatoolbar-alx_ns_ph:AlexaToolbar/alx-4.0.1
cache-control:no-cache
pragma:no-cache
referer:https://armen.jahanbani.ir/home
user-agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
我甚至试图通过添加
Header-append-content-encoding:gzip
来强制服务器压缩文件,但这也不起作用,并得到了一个错误

我应该使用.htaccess和服务器,还是我的文件有问题


谢谢

您是否尝试过直接从WebAdmin启用gzip?您也可以在那里添加可压缩类型,这样设置gzip对我来说更容易。

您必须在项目中安装一个名为“compression”的节点包,这将使angular项目能够使用gzip压缩

npm install --save compression

是的,我尝试从中启用gzip,但没有成功。我不知道到底出了什么问题。简单地说,我在wordpress网站上使用.htaccess方法,它可以工作。您有权访问Apache httpd.conf文件吗?很遗憾,我没有访问httpd.conf的权限。主域名已经通过wordpress创建,运行良好!我想还有什么东西不见了。
npm install --save compression