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

Discussion in 'Bug Reports' started by MikeDVB, Apr 22, 2010.

  1. MikeDVB

    MikeDVB Well-Known Member

    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: Apr 28, 2010
  2. NiteWave

    NiteWave Administrator

    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.
  3. MikeDVB

    MikeDVB Well-Known Member

    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?
  4. NiteWave

    NiteWave Administrator

    yes, agree with you. the redefinition is from cPanel, if I remember correctly.
  5. MikeDVB

    MikeDVB Well-Known Member

    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: Apr 23, 2010
  6. NiteWave

    NiteWave Administrator

    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.
  7. MikeDVB

    MikeDVB Well-Known Member

    Easier to just add application/javascript to the gzip line in LiteSpeed (doesn't require shell access or anything).
  8. NiteWave

    NiteWave Administrator

    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. Jamesc

    Jamesc New Member

    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. NiteWave

    NiteWave Administrator

    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

    GZIP Compression --> Compressible Types --> application/javascript
    Expires Settings --> Expires By Type --> application/javascript=A604800
  11. Jamesc

    Jamesc New Member

    cool. That worked perfectly:D

Share This Page