Forum Topic: gzip not working for my two min.js files

Forum: .htaccess Forum : Basics • Posted by Ralf Koller • Updated:

I am using the all in one solution provided in the book but somehow i've noticed today with yslow and google pagespeed that my two js files are not compressed with gzip. I am using:

<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>
		FilterDeclare COMPRESS
		FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css
		FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html
		FilterProvider COMPRESS DEFLATE resp=Content-Type $text/javascript
		FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain
		FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml
		FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript
		FilterChain COMPRESS
		FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no
	</IfModule>
	<IfModule !mod_filter.c>
		AddOutputFilterByType DEFLATE text/css text/html text/plain text/xml
		AddOutputFilterByType DEFLATE text/javascript application/javascript
	</IfModule>
	<IfModule mod_setenvif.c>
		BrowserMatch ^Mozilla/4 gzip-only-text/html
		BrowserMatch ^Mozilla/4\.0[678] no-gzip
		BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
		SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
	</IfModule>
	<IfModule mod_headers.c>
		Header append Vary User-Agent env=!dont-vary
		Header append Vary Accept-Encoding
	</IfModule>
</IfModule>

My two minified js files:

main.min.js
pre.min.js

inside my wp themes folder are listed as not compressed. But basically javascript is listed in the htaccess snippet as to compress. I am a bit confused. :/ Best regards Ralf

3 Replies to “gzip not working for my two min.js files”

Jeff Starr
Posted by Jeff Starr

Can you say one way or another that the technique either worked or didn't work on your server at some point? That would tell us if something changed or if maybe a required module is not installed. For example, did the technique work for other files at some point?

Posted by Ralf Koller •

Ahhhhh now i figured the difference. Ok if i am serving my site locally via mamp, get the ip for my connection to the net via whatismyip and then access the site via 123.123.23.23:8888/mypage/ (port 8888 is forwarded to my computer in the router - the ip is completely random for illustration purposes) then also my two js files get gzipped properly when tested with yslow (i get an A for gzip) and google pagespeed (i get no gzip error). but when i try the same with the test version online on the domain of my client i get the main.min.js and pre.min.js not compressed. so i guess i probably have to check the httpd.conf file to see if there are any related parts that interfere? but basically i thought htaccess would be an override for httpd.conf settings. hmmm odd anyway.

Jeff Starr
Posted by Jeff Starr

Sounds like you've got the situation under control :)