Javascript aggregation issue with new server I have a new VPS Host and have cloned my existing live site from my current VPS Host. On the new host, there is an issue with JS aggregation and I am hoping someone might recognize what this is and how to solve it. 

Generally with JS aggregation set at /admin/config/development/performance, Javascript breaks sitewide, both front end and backend, logged in and non-logged in. I checked permissions and the JS directiory at /sites/default/files/js/ and it seems fine, files are writing to this directory (both the JS files and the GZipped ones). 

When I view the raw code of any of these files, the code is fine (not corrupt). I have also tried switching this off, clearing cache, switching back on, clearing browser cache and even deleting the directory which Drupal did and then recreated without any issue. I checked my PHP info file (5.2.17) and it shows this under PHP Variables _SERVER["HTTP_ACCEPT_ENCODING"] - gzip,deflate,sdch so that seems ok. However my old server's PHP info file also had gzip,deflate,sdch under an additional heading called "HTTP Headers Information". 

But here is the real tell-tale, I think, when I view the code of my webpage with Chrome web inspector and look in Console, I see as many JS errors as there are aggregated files. (5 or 6 I think). The error is: Uncaught SyntaxError: Unexpected token ILLEGAL If I then view the corresponding JS file, I see this:



So somehow, the aggregated JS files are turning into gibberish characters and the errors are thrown. I have spoken with my webhost and we tried some things but nothing worked. They had me put this code into .htaccess but it did not work:

[root@host ~]# httpd -L | grep deflate
DeflateFilterNote (mod_deflate.c)
DeflateWindowSize (mod_deflate.c)
DeflateBufferSize (mod_deflate.c)
DeflateMemLevel (mod_deflate.c)
DeflateCompressionLevel (mod_deflate.c)


Also I was not exactly sure where in .htaccess to put it. (under &lt;IfModule mod_headers.c&gt; perhaps?) At any rate this did nothing to help matters no matter where I tried that code. I feel like this is a bit of a needle in a haystack and might be tricky to fix but I am curious if anyone recognizes what might be going on so i can fix it. 

** I should also note that litespeed Server is running on top of this so not sure if there are nay issues with that. I have not looked into this yet.
It's likely that your web server isn't sending the correct Content-Type or Content-Encoding header for compressed files.

Adding one of these to your httpd.conf file should solve the problem:

AddType application/x-gzip .gz .tgz


or 

AddEncoding x-gzip .gz .tgz


There should be comments in your httpd.conf file that will help you determine which one's most appropriate for your situation (search for &lt;IfModule mime_module&gt; in that file if you're interested).