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-开发者_如何学JAVAgzip
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
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.
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
精彩评论