0

This platform I'm working on uses some mechanics to determine if it should do a <script> link to a straight up .js file or a .js.gz file, depending on browser type and version.

On the current server, everything works fine, and both js and js.gz files work, and the javascript is executed in the browser. However, transfer it all over, verbatim, to a new server, and suddenly Firefox stops using the gz files. It will download them (as can be seen using Firebug) but it's not executing them.

Any ideas on why the gzipped files aren't being used properly?

Response headers From Old

Date              Thu, 25 Nov 2010 17:06:32 GMT
Server            Apache
Last-Modified     Mon, 22 Nov 2010 21:31:00 GMT
Etag              "55808a3-3f1e-4ceae114"
Accept-Ranges     bytes
Content-Length    16158
Keep-Alive        timeout=15, max=100
Connection        Keep-Alive
Content-Type      application/javascript
Content-Encoding  gzip

Response Headers from New

Date               Thu, 25 Nov 2010 17:00:11 GMT
Server             Apache/2.2.17 (CentOS)
Last-Modified      Thu, 25 Nov 2010 16:11:00 GMT
Etag               "693c304-4178-495e2da08cd00"
Accept-Ranges      bytes
Content-Length     16760
Connection         close
Content-Type       application/x-gzip

I'm going to assume it's from the Content-Encoding and Type, though I've no idea how to change this.

FIX Taking the answers and comments into account, I made the following changed to /etc/httpd/conf/httpd.conf, where commented (#) lines are what was there, uncommented is my replacement:

# Technically just uncommented this line
AddEncoding x-gzip .gz .tgz

#AddType application/x-gzip .gz .tgz
AddType application/x-gzip .tgz
AddType application/javascript .gz
5
  • 3
    Any hint on the Content-Type that would be different on both servers?
    – Danosaure
    Nov 25, 2010 at 16:49
  • Yes, Content-Type is probably the problem. Make sure it’s javascript on the new server als well. Also check the HTTP-response headers that gzip compression is indicated.
    – Kissaki
    Nov 25, 2010 at 16:53
  • @Danosaure and @Kissaki, i'm pretty sure mime type doesn't matter - for historical reasons half the scripts at my work are generated w/ php and served as text/html and they work fine (Please note i am in no way responsible for any of these scripts, don't blame me!) Nov 25, 2010 at 16:59
  • @Danosaure, @Kissaki Thanks for pointing me in the right direction. Changed some settings in httpd.conf (will later try using a straight .htaccess file instead) but managed to change the headers sent, and got it working.
    – Tarka
    Nov 25, 2010 at 17:42
  • Hurray... If you post what you changed in httpd.conf, it would help others with the same trouble in the future.
    – Danosaure
    Nov 26, 2010 at 14:48

2 Answers 2

1

This will be a server side setting/module - clients don't know how to handle gziped files however they usually know how to handle files compressed in transit as long as you tell them how you've compressed them using a Content-Encoding header.

basicly i think you'll find that the server isn't sending a Content-Encoding: gzip header on the new server, but it is on the old.

1
  • Checked the headers, played around in httpd.conf, and got it sending the right Content-Type and Content-Encoding. force-refresh the page, and everything loaded properly. Thanks for helping to point me in the right direction.
    – Tarka
    Nov 25, 2010 at 17:43
0

If you happen to use Apache, it might be possible that your former web server had MultiViews enabled but your current web server doesn’t. Try to enable it in your current server too (at least for that directory):

Options +MultiViews

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.