18

When I refresh my website in less than 2-3 minutes, Firebug shows these nice requests:

1. /core.css          304 Not modified
2. /core.js           304 Not modified
3. /background.jpg    304 Not modified

BUT when I refresh after >3 minutes, I get:

1. /core.css          200 OK
2. /core.js           200 OK
3. /background.jpg    304 Not modified

Why my CSS and JS files are downloaded again and images aren't?

I'm using ASP.NET MVC 3, I DON'T use [OutputCache], and in my /Content folder (where all css, js and img files live in subfolders) I have this Web.config:

<configuration>
    <system.webServer>
        <staticContent>
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" />
        </staticContent>
    </system.webServer>
</configuration>

which sets HTTP header Cache-Control: max-age=86400 ONLY. So basically CSS, JS and images are treated the same way, but somehow CSS and JS don't get cached for a longer period... why is that?

2
  • 1
    Why don't you use [OutputCache]? Commented Sep 5, 2010 at 3:23
  • Because this is static content. Here I'm interested about static content caching, I doubt that it has anything to do with ASP.NET MVC, but I mentioned it because I don't know everything and maybe there's some solution... Commented Sep 5, 2010 at 11:06

3 Answers 3

13

Hopefully this will help: http://www.iis.net/ConfigReference/system.webServer/staticContent/clientCache

The <clientCache> element of the <staticContent> element specifies cache-related HTTP headers that IIS 7 and later sends to Web clients, which control how Web clients and proxy servers will cache the content that IIS 7 and later returns...

Sign up to request clarification or add additional context in comments.

1 Comment

The effects of turning this on are tremendous if you're using jQuery with a couple of different plug-ins e.g jqGrid, at a minimum the stuff flying by in fiddler has been reduced.
2

This occurs with IIS or with the Visual Studio web server? for some time perceived this behavior while developing (using the VS web server), but when publish it in IIS this not occur anymore.

Comments

0

Could this be the bug in Firefox described here ?

You could test this by opening the same page in another browser and check what get's loaded using Fiddler or some other tool.

2 Comments

I just noticed that this bug was resolved at 2010-05-09. So this fix could be in the latest version of FF.
I do have the latest version :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.