即使日志显示它正常工作,IIS压缩也会在响应中缺少内容编码(IIS Compression missing content

编程入门 行业动态 更新时间:2024-10-09 06:23:28
即使日志显示它正常工作,IIS压缩也会在响应中缺少内容编码(IIS Compression missing content-encoding in response even though logs show it working)

我想用gzip压缩来提供.js文件

我正在使用IIS 7.5并启用了动态和静态内容压缩。

在IIS日志中,我可以看到以下日志,它显示它似乎正在工作,因为它在“GENERAL_RESPONSE_HEADERS”事件中显示“Content-Encoding:gzip”

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="WWW Server" Guid="{3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83}"/> <EventID>0</EventID> <Version>1</Version> <Level>4</Level> <Opcode>47</Opcode> <Keywords>0x0</Keywords> <TimeCreated SystemTime="2017-03-29T23:40:41.555Z"/> <Correlation ActivityID="{8000000D-0003-FA00-B63F-84710C7967BB}"/> <Execution ProcessID="12296" ThreadID="13868"/> <Computer>AUD64909W0</Computer> </System> <EventData> <Data Name="ContextId">{8000000D-0003-FA00-B63F-84710C7967BB}</Data> <Data Name="Headers">Transfer-Encoding: chunked Content-Type: application/javascript Content-Encoding: gzip Last-Modified: Wed, 29 Mar 2017 20:33:32 GMT Accept-Ranges: bytes ETag: &quot;d6af72bbcba8d21:0&quot; Vary: Accept-Encoding Server: Microsoft-IIS/10.0 X-Powered-By: ASP.NET </Data> </EventData> <RenderingInfo Culture="en-NZ"> <Opcode>GENERAL_RESPONSE_HEADERS</Opcode> </RenderingInfo> <ExtendedTracingInfo xmlns="http://schemas.microsoft.com/win/2004/08/events/trace"> <EventGuid>{D42CF7EF-DE92-473E-8B6C-621EA663113A}</EventGuid> </ExtendedTracingInfo> </Event>

但是,在Fiddler或Chrome开发工具中查看时,响应标头未显示Content-Encoding。

HTTP/1.1 200 OK Transfer-Encoding: chunked Content-Type: application/javascript Last-Modified: Wed, 29 Mar 2017 20:33:32 GMT Accept-Ranges: bytes ETag: "d6af72bbcba8d21:0" Vary: Accept-Encoding Server: Microsoft-IIS/10.0 X-Powered-By: ASP.NET Date: Thu, 30 Mar 2017 00:57:20 GMT

任何想法为什么这不起作用

I'm wanting to serve a .js file with gzip compression

I'm using IIS 7.5 and have dynamic and static content compression enabled.

In the IIS logs I can see the following log which shows that it appears to be working as it shows "Content-Encoding: gzip" in the "GENERAL_RESPONSE_HEADERS" event

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="WWW Server" Guid="{3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83}"/> <EventID>0</EventID> <Version>1</Version> <Level>4</Level> <Opcode>47</Opcode> <Keywords>0x0</Keywords> <TimeCreated SystemTime="2017-03-29T23:40:41.555Z"/> <Correlation ActivityID="{8000000D-0003-FA00-B63F-84710C7967BB}"/> <Execution ProcessID="12296" ThreadID="13868"/> <Computer>AUD64909W0</Computer> </System> <EventData> <Data Name="ContextId">{8000000D-0003-FA00-B63F-84710C7967BB}</Data> <Data Name="Headers">Transfer-Encoding: chunked Content-Type: application/javascript Content-Encoding: gzip Last-Modified: Wed, 29 Mar 2017 20:33:32 GMT Accept-Ranges: bytes ETag: &quot;d6af72bbcba8d21:0&quot; Vary: Accept-Encoding Server: Microsoft-IIS/10.0 X-Powered-By: ASP.NET </Data> </EventData> <RenderingInfo Culture="en-NZ"> <Opcode>GENERAL_RESPONSE_HEADERS</Opcode> </RenderingInfo> <ExtendedTracingInfo xmlns="http://schemas.microsoft.com/win/2004/08/events/trace"> <EventGuid>{D42CF7EF-DE92-473E-8B6C-621EA663113A}</EventGuid> </ExtendedTracingInfo> </Event>

However the response headers when viewed in Fiddler or Chrome dev tools are not showing Content-Encoding.

HTTP/1.1 200 OK Transfer-Encoding: chunked Content-Type: application/javascript Last-Modified: Wed, 29 Mar 2017 20:33:32 GMT Accept-Ranges: bytes ETag: "d6af72bbcba8d21:0" Vary: Accept-Encoding Server: Microsoft-IIS/10.0 X-Powered-By: ASP.NET Date: Thu, 30 Mar 2017 00:57:20 GMT

Any ideas why this ain't working

最满意答案

修复:问题是我的机器上的防病毒软件正在剥离“Content-Encoding”响应标头。

Fixed: Issue was the antivirus on my machine was stripping out the "Content-Encoding" response header.

更多推荐

本文发布于:2023-08-02 13:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1375794.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:会在   内容   工作   日志   missing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!