Apache 2.4 with mod_deflate compress CSS but not JS
.htaccess
# Proper MIME types for all files
<IfModule mod_mime.c>
AddType application/javascript js
AddType text/css css
</IfModule>
<IfModule mod_deflate.c>
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/javascript text/css
</IfModule>
</IfModule>
Response of site.com/src/css/core.css
is OK (encoded: 30.38 KiB / decoded: 146.31 KiB)
Status: HTTP/1.1 200 OK
Connection: close
Expires: Tue, 06 Oct 2015 14:55:59 GMT
Date: Mon, 06 Oct 2014 14:55:59 GMT
Content-Type: text/css; charset=utf-8
Server: Apache
Accept-Ranges: bytes
Last-Modified: Mon, 06 Oct 2014 13:13:31 GMT
Vary: Accept-Encoding
Cache-Control: max-age=31536000
Transfer-Encoding: chunked
Content-Encoding: gzip
Vary: Accept-Encoding
Response of site.com/src/js/core.js
is KO
Status: HTTP/1.1 200 OK
Connection: close
Content-Length: 236437
Expires: Tue, 06 Oct 2015 14:57:50 GMT
Date: Mon, 06 Oct 2014 14:57:50 GMT
Content-Type: application/javascript; charset=utf-8
Server: Apache
Accept-Ranges: bytes
Last-Modified: Mon, 06 Oct 2014 12:49:48 GMT
Vary: Accept-Encoding
Cache-Control: max-age=31536000
http.conf (active modules)
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule alias_module modules/mod_alias.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule expires_module modules/mod_expires.so
LoadModule filter_module modules/mod_filter.so
LoadModule headers_module modules/mod_headers.so
LoadModule include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule cache_disk_module modules/mod_cache_disk.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule status_module modules/mod_status.so
Why, apache 2.4 not compress JS, but compress CSS??
everything looks correct ...
I remember that I have had the same thing with Forefront TMG
proxy firewall which by default does not pass the Content-Encoding
header in the request for application/javascript
type.
Check your firewall if you have one...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.