[英]How do I set the http 'accept' header for JS and CSS files requested by an HTML document?
I am trying to configure some assets on the Rackspace Cloudfiles CDN to be sent to clients with gzip encoding. 我正在尝试在Rackspace Cloudfiles CDN上配置一些资产,以使用gzip编码发送给客户端。 As far as I can tell according to their website (http://www.rackspace.com/blog/cloud-files-cdn-compresses-at-the-edge/), any request with 'Accept-encoding: gzip' and 'Accept: application/x-javascript' will be sent down with gzip. 据我所知,根据他们的网站(http://www.rackspace.com/blog/cloud-files-cdn-compresses-at-the-edge/),任何带有'Accept-encoding:gzip'的请求和“接受:应用程序/ x-javascript”将与gzip一起发送。 The request is being made with 'accept-encoding: gzip', but 'accept: / '. 该请求是使用'accept-encoding:gzip'发出的,但使用'accept: / '发出的。
Is there a way for me to get the browser to request the JS file as 'application/x-javascript', or do I need to do something at the file level to send the resource down with the right mime-type? 我是否可以让浏览器将JS文件请求为“ application / x-javascript”,还是我需要在文件级别执行一些操作以将资源以正确的mime类型发送出去? Same for CSS. CSS也一样。
We solved this by explicitly setting "Content-Type: application/x-javascript" in our deployment script using the Rackspace Cloud Files API Ruby gem. 我们通过使用Rackspace Cloud Files API Ruby gem在部署脚本中显式设置“ Content-Type:应用程序/ x-javascript”来解决此问题。 This solved the problem. 这样就解决了问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.