简体   繁体   English

如何为HTML文档请求的JS和CSS文件设置http'accept'标头?

[英]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.

相关问题 如何将 CSS 和 js 文件捆绑到一个 HTML 文件中? - How do I bundle CSS and js files into a single HTML file? Nginx:我想http2_push目录中的所有js和css文件怎么办? - Nginx: I want to http2_push all js and css files in a directory how can I do? 如何使用webpack来要求带有内联CSS,JS和PNG的HTML文档 - How do I use webpack to be able to require an HTML document with inlined CSS, JS and PNG 触发事件后,如何在HTML文件及其相应的js和css文件之间转换? - How do I transition between HTML files and their corresponding js and css files after an event is triggered? 如何将自定义HTTP标头发送到Node.js - How do I send custom HTTP header to Node.js 从 HTML,CSS,JS 转换为 JSX, Z2C56C3602580420DFBEDZ,JS 时,如何在反应中链接我的 javascript 文件? - How do I link my javascript files in react when converting from HTML,CSS,JS into JSX, CSS, JS? 如何将 CSS 和 JS 文件链接到我的 github 页面的 HTML 文件? - How do I link CSS and JS files to my HTML file for github pages? 使用FormKeep,如何将请求的Accept标头设置为application / javascript - Using FormKeep, how do I set the Accept header of the request to application/javascript 如何使用单个javascript properties.js文件在多个HTML文件中设置变量? - How do I use a single javascript properties.js file to set variables in multiple HTML files? 除了黑魔法,当通过HTTP vs HTTPS获取页面时,什么会导致js / css文件包含在其包含的html文档中? - Besides black magic, what could cause inclusion of js/css files in their containing html document when fetching a page over http vs https?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM