MVC4捆绑缓存头 [英] MVC4 Bundling Cache Headers
问题描述
我想改变一个包请求发出的缓存头。目前,它是由用户代理
不同,但我不希望它,有没有办法改变一个包请求发送的头?
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?
在快速浏览一下在 System.Web.Optimization
组装可以看我的头得到设定 Bundle.SetHeaders
这是一个私有的静态函数,所以我不认为它可能,虽然我很乐意被证明是错误的。
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.
推荐答案
这是不是我们今天当前公开。我们只能暴露在BundleRepsonse可缓存属性,一个IBundleTransform可能改变。是的,我们明确地设置了以下几件事:
This isn't something that we currently expose today. We only expose the Cacheability property on the BundleRepsonse 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.
这篇关于MVC4捆绑缓存头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!