I want to change the cache headers sent from a bundle request. Currently it is varying by User-Agent
but I don't want it to, is there a way to change the headers sent by a bundle request?
After a quick look in the System.Web.Optimization
assembly I can see the headers get set in Bundle.SetHeaders
which is a private static function so I don't think its possible although I would love to be proven wrong.
This isn't something that we currently expose today. We only expose the Cacheability property on the BundleResponse that a IBundleTransform could change. And yes we explicitly set the following things:
HttpCachePolicyBase cachePolicy = context.HttpContext.Response.Cache;
cachePolicy.SetCacheability(bundleResponse.Cacheability);
cachePolicy.SetOmitVaryStar(true);
cachePolicy.SetExpires(DateTime.Now.AddYears(1));
cachePolicy.SetValidUntilExpires(true);
cachePolicy.SetLastModified(DateTime.Now);
cachePolicy.VaryByHeaders["User-Agent"] = true;
We have a work item our backlog to open this up and make this more extensible/customizable in the future.