Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Apache 2.4 gzip compression not work on JS but work on CSS |
|
Author |
|
skillsfactory
Joined: 27 Sep 2013 Posts: 11 Location: Italy
|
Posted: Mon 06 Oct '14 19:48 Post subject: Apache 2.4 gzip compression not work on JS but work on CSS |
|
|
Apache 2.4 with mod_deflate compress CSS but not JS
.htaccess
Code: | # 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)
Code: | 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 (not compressed!)
Code: | 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)
Code: | 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?? |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Tue 07 Oct '14 11:41 Post subject: |
|
|
Sometimes the header varies for js files
Code: |
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/php text/css text/js text/javascript text/javascript-x application/x-javascript font/truetype
AddOutputFilterByType DEFLATE application/javascript application/rss+xml
DeflateCompressionLevel 9
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
</IfModule>
|
post #5000 |
|
Back to top |
|
skillsfactory
Joined: 27 Sep 2013 Posts: 11 Location: Italy
|
Posted: Tue 07 Oct '14 13:56 Post subject: |
|
|
Thank you, now it works! |
|
Back to top |
|
|
|
|
|
|