Cache busting a local browser cache but ensuring response from Azure CDN and not from origin server (Web Role)

StackOverflow https://stackoverflow.com/questions/13223965

Question

I am trying to make a HEAD request to an item on Azure CDN (production site) but want to avoid the response coming from either my local browser cache, nor from the origin server (my web role). This is going to be a heavily trafficked web site and the content is all static and thus cached on Azure CDN from a /cdn folder in my web role.

I have solved the problem of avoiding my local browser cache by calling:

$.ajaxSetup({cache: false});

Also my HEAD request is being used to simply retrieve the Response Date as all I want is a guaranteed current time in GMT (Azure is all set to GMT):

$.ajax({
    type: "HEAD",
    async: true,
    url: "small.png",
    success: function (message, text, response) {
        doSomething(response.getResponseHeader("Date"));
    }
});

Now I am guaranteeing that my response is absolutely not being fulfilled by a cached copy on my browser, but I am not sure how to verify if the response is coming from Azure CDN or the origin server (web role). I want to guarantee that if "small.png" is on Azure CDN, that my response comes from there. Basically, I need to confirm that my origin server will not be bombarded by requests and that the CDN will throttle 99.999999% of the requests including this one. However, because of my cache-busting prior to the HEAD request ($.ajaxSetup({cache: false}); which appends a unique querystring onto the request, I am not sure if Azure CDN is deciding to forward the request on to the origin server.

NOTE that via the Azure portal, I have left "Enable Querystring" unchecked on my CDN. I THINK this is sufficient to satisfy me, but I want the warm and fuzzy feeling that indeed my response is coming from Azure CDN and not origin. Is there any indicator in Fiddler that will prove to me my response is from CDN(proxy server) rather than the origin server?

Currently I have 30 minute cache expires on everything but I will adjust/optimize this when we go live.

Was it helpful?

Solution

Keeping "enable query string" unchecked does exactly what you want.

As to determining whether the CDN went back to the origin server on a given request, you own the origin server, right? So you can see there if you were hit or not. I'm not sure there's a way to tell from just looking at the CDN's response whether it was a cache hit or a cache miss.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top