My application has a custom HttpModule
that we use for some advanced logging. All it does is add a couple of custom headers to the HTTP response.
The problem I'm having is that when this module is enabled, .CSS files are being returned with an HTTP header of Cache-Control: no-cache
. When I turn off the module, I get what I'm expecting which is Cache-Control:max-age=2419200
.
I have my cache enabled with:
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="28.00:00:00"/>
</staticContent>
I tried to comment out the adding of the custom headers in our HttpModule
, but that didn't work.
Also, this is only causing problems for the .CSS files. .JS, .PNG, and .GIF for example are all working as I would expect. I can't seem to figure out why .CSS is special.
Not sure why just having that module is causing the cache header to work like that. Any thoughts?
I tried this on IIS7 and IIS7.5. (Actually it is running in Windows Azure but I don't think that makes a difference).
Edits: The web.config is very large. I don't want to put the whole thing here. Here is more it:
<system.webServer>
<handlers>
<add name="pngHandler" path="*.png" verb="*" type="CompanyXXX.Applications.Portal.PngHttpHandler,Portal.System" modules="ManagedPipelineHandler" scriptProcessor="" resourceType="Unspecified" requireAccess="Script" preCondition="" />
<add name="gifHandler" path="*.gif" verb="*" type="CompanyXXX.Applications.Portal.GifHttpHandler,Portal.System" modules="ManagedPipelineHandler" scriptProcessor="" resourceType="Unspecified" requireAccess="Script" preCondition="" />
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
<modules>
<add name="CookieManagerModule" type="CompanyXXX.Web.CookieManagerModule, Framework.Web" preCondition="" />
<add name="AuthenticationModule" type="CompanyXXX.Applications.Portal.AuthenticationModule,Portal.System" preCondition="" />
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" preCondition=""/>
<add name="LoggingModule" type="CompanyXXX.Applications.Portal.LoggingModule,Portal.System"/>
<add name="RequestReduce" type="RequestReduce.Module.RequestReduceModule, RequestReduce" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
<urlCompression doDynamicCompression="true" doStaticCompression="true" dynamicCompressionBeforeCache="false"/>
<httpCompression sendCacheHeaders="true">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
</httpCompression>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="28.00:00:00"/>
</staticContent>
</system.webServer>
As for the code, I can't post it here. All I can say is that it only adds 3 headers to the response.