[Resolved] mime.properties - js=application/x-javascript vs js=application/javascript

MikeDVB

Well-Known Member
#1
I found that LiteSpeed was not gzip compressing .js files with the type application/x-javascript in the gzip list (which is by default) and the same mime type inside of mime.properties.

I tested using this test: http://www.whatsmyip.org/http_compression/

When doing a curl -I of the .js file I was getting this: Content-Type: application/javascript

I tried adding that to the gzip compression line but that simply did not work - I had to add it to the compression line as well as change the mime type in the mime.properties to get gzip compression working for .js files.

Do these settings need to be changed for both for it to work or what? Setting it to application/x-javascript in mime.properties simply wasn't working for FireFox, IE, or curl -I as near as I could tell.
 
Last edited by a moderator:

NiteWave

Administrator
#2
another trick is to add a MIME type, say

js2 application/javascript

the issue you described is because .js type redefined from x-javascript to javascript somewhere in http.conf or .htaccess. if no such redefinition, litespeed by default will compress .js well as x-javascript.
 

MikeDVB

Well-Known Member
#3
another trick is to add a MIME type, say

js2 application/javascript

the issue you described is because .js type redefined from x-javascript to javascript somewhere in http.conf or .htaccess. if no such redefinition, litespeed by default will compress .js well as x-javascript.
It's a cPanel server - we didn't change any mime types on the server itself or in LiteSpeed until we noticed that it simply was not compressing javascript.

I mean I have no problem making the changes to the mime.properties file and the compression settings in LiteSpeed on each install but realistically why should we have to do this?
 

MikeDVB

Well-Known Member
#5
yes, agree with you. the redefinition is from cPanel, if I remember correctly.
I actually just added application/javascript to the default gzip line:


Any chance that maybe we can get application/javascript added to this line by default, surely it's not going to hurt anything.
 
Last edited:

NiteWave

Administrator
#6
in litespeed, you can try my previous suggestion: set js2 as MIME type:application/javascript. this change may be enough(can remove other changes). -- as a cPanel patch.
 

MikeDVB

Well-Known Member
#7
in litespeed, you can try my previous suggestion: set js2 as MIME type:application/javascript. this change may be enough(can remove other changes). -- as a cPanel patch.
Easier to just add application/javascript to the gzip line in LiteSpeed (doesn't require shell access or anything).
 

NiteWave

Administrator
#8
may need add "application/javascript" to "Expires By Type"

Server-->General-->Expires By Type

the root cause in summary is because there is following directive somewhere in cPanel:
AddType application/javascript .js
which override litespeed's default MIME type for .js:
application/x-javascript .js
 
#9
After changing the said changes, the files with .js still do not perform gzip
compression. I am using litespeed v4.0.14.
Here are my settings.

GZIP Compression --> Compressible Types --> application/x-javascript
Expires Settings --> Expires By Type --> application/x-javascript=A604800

Please advise.
 
#10
Code:
GZIP Compression --> Compressible Types --> application/x-javascript
Expires Settings --> Expires By Type --> application/x-javascript=A604800
application/x-javascript already there, should add application/javascript

i.e.,
Code:
GZIP Compression --> Compressible Types --> application/javascript
Expires Settings --> Expires By Type --> application/javascript=A604800
 
Top