Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebResource.axd and HTTP Headers

Our site just moved from .NET 1.1 to .NET 3.5, and in the process updated our 3rd party server controls. One of these packages uses javascript provided via WebResource.axd. These are included as normal <script src="" /> tags.

Watching the traffic, however, I see that these javascript files are coming across with headers that prevent client-side caching. And we're talking a lot of javascript. The headers in question:

Cache-control: no-cache, no-store
pragma: no-cache
Expires: -1

Are these headers configurable in .NET somewhere? Can I intercept these requests short of building an HttpModule? Is this something I can blame the control vendor for? <brandish weapon="blameGun" />

Thanks,

Baron

like image 566
BnWasteland Avatar asked Jan 22 '26 13:01

BnWasteland


1 Answers

You could try:

HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Public);

The other types of HttpCacheability are documented here:

http://msdn.microsoft.com/en-us/library/system.web.httpcacheability.aspx

Edit:

You can throw this in your Global.asax file instead of a module:

void Application_AuthorizeRequest(object sender, EventArgs e)
{
    if (Request.Path.IndexOf("WebResource.axd") > -1)
    {
        Response.Cache.SetCacheability(HttpCacheability.Public);
    }
}
like image 198
John Rasch Avatar answered Jan 24 '26 16:01

John Rasch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!