本文整理汇总了C#中System.Web.HttpResponseBase.DisableUserCache方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponseBase.DisableUserCache方法的具体用法?C# HttpResponseBase.DisableUserCache怎么用?C# HttpResponseBase.DisableUserCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpResponseBase
的用法示例。
在下文中一共展示了HttpResponseBase.DisableUserCache方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyCacheControl
/// <summary>
/// Define valid cache control values
/// </summary>
private void ApplyCacheControl(CacheItem cacheItem, HttpResponseBase response) {
if (_maxAge > 0) {
var maxAge = new TimeSpan(0, 0, 0, _maxAge); //cacheItem.ValidUntilUtc - _clock.UtcNow;
if (maxAge.TotalMilliseconds < 0) {
maxAge = TimeSpan.FromSeconds(0);
}
response.Cache.SetCacheability(HttpCacheability.Public);
response.Cache.SetMaxAge(maxAge);
}
response.Cache.VaryByParams["*"] = true;
response.DisableUserCache();
// keeping this examples for later usage
// response.DisableKernelCache();
// response.Cache.SetOmitVaryStar(true);
// an ETag is a string that uniquely identifies a specific version of a component.
// we use the cache item to detect if it's a new one
if (HttpRuntime.UsingIntegratedPipeline) {
if (response.Headers.Get("ETag") == null) {
response.Cache.SetETag(cacheItem.GetHashCode().ToString(CultureInfo.InvariantCulture));
}
}
if (_varyQueryStringParameters != null) {
foreach (var queryStringParam in _varyQueryStringParameters) {
response.Cache.VaryByParams[queryStringParam] = true;
}
}
foreach (var varyRequestHeader in _varyRequestHeaders) {
response.Cache.VaryByHeaders[varyRequestHeader] = true;
}
}