从我的服务器发送的静态内容(例如:.css、.js)是否被压缩?
当我写最初的问题时,我看到了这篇帖子。
我部署了我的网站并启用了静态内容压缩。但还是收到了下面的回复。
第一次运行
第二次运行
我可以明显看到响应大小已经减小。这可能是一个愚蠢的问题,但这只是为了满足我自己的好奇心。如果内容是压缩的,为什么它在 fiddler 中显示为未压缩?
编辑: ..并且内容也可以在第一个请求时进行 gzip 压缩吗?
更新: 我通过使用 deflate 而不是 gzip 解决了我的问题... go Figgure :/ (通过比较,苹果与苹果,而不是 401 错误。)感谢所有评论。我还找到了收到的 401 错误的答案:链接
As I was writing my initial question I saw this post.
I deployed my site and enabled static content compression. But still received the following response.
1st Run
2nd Run
I can obviously see that the response size has decreased. This might be a stupid question, but its just to satisfy my own curiosity. If the content is compressed why would it show up as uncompressed in fiddler?
EDIT:
..and can the content be gzipped on the first request as well?
UPDATE:
I solved my issue by using deflate instead of gzip... go figgure :/ (and by comparing, apples with apples, and not 401 errors.) Thanks for all the comments though. Also i found the answer to the 401 errors i was receiving : Link
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
第二个响应的状态代码为 401。我怀疑它是否包含 javascript 的实际内容,而这 341 字节是从服务器发送的错误响应。
The second response has the status code 401. I doubt it contains the actual content of the javascript, rather these 341 bytes are the error response sent from the server.
因为 Fiddler 理解压缩并自动解压缩输出以方便您以友好的方式显示它。与 FireBug 和浏览器中的开发人员工具栏等插件的方式相同。但实际上通过网络发送的是 gzip 压缩内容。
Because Fiddler understands compression and automatically decompresses the output for your own convenience in order to display it in a friendly manner. The same way plugins such as FireBug and developer toolbars in browsers do. But what is actually sent on the wire is a gzip compressed content.
发生的事情是(根据我在 Wiktors 答案下的评论)你没有比较同类。
您对资源 jquery.jGrid.src.js 的初始请求正在生成 401 Unauthorized 错误,然后导致您的浏览器使用正确的凭据与服务器重新协商请求,然后导致资源返回状态代码为200 好
What is happening is that (as per my comments under Wiktors answer) is that you are not comparing like with like.
Your initial request to resource jquery.jGrid.src.js is generating a 401 Unauthorized error which then leads to your browser renegotiating the request with the server with the correct credientals, which then leads to the resource to be returned with a status code of 200 OK