.netgoogle-chromefirefoxcachingcache-control

Issue with Chrome not Utilizing Cache for .NET Project I'm encountering a puzzling behavior


Chrome seems to be ignoring cache directives for certain static files. Here's the relevant excerpt from my web.config as i use IIS:

<location path="Scripts">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
    <system.webServer>
        <staticContent>
            <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="100.00:00:00" />
        </staticContent>
    </system.webServer>
</location>

I have a file named app2.css for the example loaded from an ASPX file like so:

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="/Themes/General/css/ant.css" rel="stylesheet" type="text/css"/>
    <link href="../Scripts/vue/Components/css/app2.css" rel="stylesheet" type="text/css" />
</asp:Content>

Upon inspecting the network traffic in Chrome, I notice that on the initial request, the response headers include the expected cache control directives:

Request:

Response:

Request Headers:

Strangely, this behavior is not observed in Firefox, which consistently loads the file from the cache as anticipated.

I've attempted to address this by adding the immutable directive to the cache control header, but it had no effect. Additionally, running Chrome with increased memory limits did not yield any improvements. i have Etag that is remain the same and last-modifeid is fine.

In a broader context, the page initiates a total of 180 requests. While approximately 70% of them load from in-memory cache in Chrome, the remaining JavaScript and CSS files continue to be fetched from the server. (talking about those with proper cache-control). i will mention the Etag remain the same for the assets and last-modified is lower then request time

I'm at a loss as to what might be causing this discrepancy between Chrome and Firefox. Any insights or suggestions on how to resolve this issue would be greatly appreciated.

i've tried adding immutiable to the cache-control.lowering max-age. minimizing assets file sizes. many other attempts that failed. checking the behavior in develop and production envirunments. from diffrent computers. chrome browser from mac and windows. and as i said. all is looking good on firefox.


Solution

  • Finaly i've manage to understand what cause this behavior in chrome. it was due to bad site certificate leading to 'not secure' error. only fixing the certificate helped. not chrome security flag coul'd bypass this issue. after fixing the certificate all assets loaded from cache as expected