3

Im really to confused as to whats going on here.

It seems the (System.Web.Optimization.)Bundle library puts a filesystem watcher on all the files it has bundled up. Whenever there is a change (say for example I tweak the contents of a CSS file), it rebuilds the bundle.

I've seen this work by making requests to the URL of a CSS bundle in Fiddler, with which it works by regenerating the CSS bundle faultlessly, 100% of the time.

However, in both Firefox and Chrome, and only sometimes, it doesn't *appear* to be hitting the webserver, and continues serving me the old, unmodified CSS.

The weird thing is, even after doing a full cache refresh (ctrl+shift+r), and even going into chrome and deleting *all* cached data, it still serves me exactly the same, old CSS file.

This makes me think the fault / issue is actually within the Bundle library -maybe fiddler is passing different request headers or something, that make the Bundle handler to behave inconsistently?

Appreciate any help with this matter as its been going on for days.

Edit: So i've put together the following code which seems to be working

...
var styleBundle = new Bundle(virtualPath, new NoCacheTransform());
...


public class NoCacheTransform : IBundleTransform
{
    public void Process(BundleContext context, BundleResponse response)
    {
        context.EnableOptimizations = false;
        context.UseServerCache = false;
        response.ContentType = "text/css";//text/css; charset=utf-8
        response.Cacheability = HttpCacheability.NoCache;
    }
}

A couple of those property assignments might not be necessary, but its more of a head up.

0

2 Answers 2

1

It might help to fingerprint the bundle? Refer to http://madskristensen.net/post/cache-busting-in-aspnet for more info.

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

3 Comments

I have tried similar (appending a querystring onto the requested css file with a randomised querystring value) and it makes no difference, making me think that it is not the browser 'at fault'.
What happens when you request the bundle file directly in Chrome/Firefox?
It serves the unchanged version.
0

My guess is this is a bug. We're seeing similar behaviour; and there are various bugs that seem to describe this open. Sadly the source is not public, and MS were unable to repro this when I contacted them; so it's gone unfixed :(

https://aspnetoptimization.codeplex.com/workitem/120 https://aspnetoptimization.codeplex.com/workitem/96 https://aspnetoptimization.codeplex.com/workitem/114

Comments

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.