コード例 #1
0
 private void UpdateCachePolicy(HttpCachePolicyBase cachePolicy)
 {
     cachePolicy.SetNoStore();
     cachePolicy.SetValidUntilExpires(false);
     cachePolicy.SetRevalidation(HttpCacheRevalidation.AllCaches);
     cachePolicy.SetCacheability(HttpCacheability.NoCache);
 }
コード例 #2
0
ファイル: FoundResult.cs プロジェクト: KarlDirck/cavity
        public override void SetCache(HttpCachePolicyBase cache)
        {
            if (null == cache)
            {
                throw new ArgumentNullException("cache");
            }

            if (!Expires.HasValue)
            {
                cache.SetCacheability(HttpCacheability.NoCache);
                return;
            }

            cache.SetCacheability(HttpCacheability.Public);
            cache.SetExpires(Expires.Value);
        }
コード例 #3
0
 public override void SetCache(HttpCachePolicyBase cache)
 {
     if (null != cache)
     {
         cache.SetCacheability(HttpCacheability.Server);
         cache.SetExpires(DateTime.UtcNow.AddDays(1));
     }
 }
コード例 #4
0
ファイル: SeeOtherResult.cs プロジェクト: KarlDirck/cavity
        public override void SetCache(HttpCachePolicyBase cache)
        {
            if (null == cache)
            {
                throw new ArgumentNullException("cache");
            }

            cache.SetCacheability(HttpCacheability.NoCache);
        }
コード例 #5
0
ファイル: CachePolicy.cs プロジェクト: dblchu/JuniorRoute
        public void Apply(HttpCachePolicyBase policy)
        {
            policy.ThrowIfNull("policy");

            if (!_hasPolicy)
            {
                return;
            }

            switch (_cacheability)
            {
                case HttpCacheability.NoCache:
                    policy.SetCacheability(_allowsServerCaching == true ? HttpCacheability.ServerAndNoCache : HttpCacheability.NoCache);
                    break;
                case HttpCacheability.Private:
                    policy.SetCacheability(_allowsServerCaching == true ? HttpCacheability.ServerAndPrivate : HttpCacheability.Private);
                    break;
                case HttpCacheability.Public:
                    policy.SetCacheability(HttpCacheability.Public);
                    break;
            }
            if (_noStore == true)
            {
                policy.SetNoStore();
            }
            if (_noTransforms == true)
            {
                policy.SetNoTransforms();
            }
            if (_clientCacheExpirationUtcTimestamp != null)
            {
                policy.SetExpires(_clientCacheExpirationUtcTimestamp.Value);
            }
            if (_clientCacheMaxAge != null)
            {
                policy.SetMaxAge(_clientCacheMaxAge.Value);
            }
            if (_allowResponseInBrowserHistory != null)
            {
                policy.SetAllowResponseInBrowserHistory(_allowResponseInBrowserHistory.Value);
            }
            if (_eTag != null)
            {
                policy.SetETag(_eTag);
            }
            if (_omitVaryStar != null)
            {
                policy.SetOmitVaryStar(_omitVaryStar.Value);
            }
            if (_proxyMaxAge != null)
            {
                policy.SetProxyMaxAge(_proxyMaxAge.Value);
            }
            if (_revalidation != null)
            {
                policy.SetRevalidation(_revalidation.Value);
            }
        }
コード例 #6
0
 void SetLongLivedCacheHeaders(HttpCachePolicyBase cache, string serverETag)
 {
     cache.SetCacheability(HttpCacheability.Public);
     cache.SetETag(serverETag);
     cache.SetExpires(DateTime.UtcNow.AddYears(1));
 }
コード例 #7
0
ファイル: BaseHttpHandler.cs プロジェクト: gmoothart/NCombo
 /// <summary>
 /// Sets the cache policy.  Unless a handler overrides
 /// this method, handlers will not allow a respons to be
 /// cached.
 /// </summary>
 /// <param name="cache">Cache.</param>
 public virtual void SetResponseCachePolicy(HttpCachePolicyBase cache)
 {
     cache.SetCacheability(HttpCacheability.NoCache);
     cache.SetNoStore();
     cache.SetExpires(DateTime.MinValue);
 }
コード例 #8
0
        private void SetCache(HttpCachePolicyBase cache, System.Net.Http.Headers.CacheControlHeaderValue cacheIn)
        {
            if (cacheIn == null)
                return;

            if (cacheIn.Public)
            {
                cache.SetCacheability(HttpCacheability.Public);
            }
            if (cacheIn.Private)
            {
                cache.SetCacheability(HttpCacheability.Private);
            }
            if (cacheIn.MaxAge != null)
            {
                cache.SetMaxAge(cacheIn.MaxAge.Value);
            }

        }
コード例 #9
0
 public static void CacheForOneMonth(HttpCachePolicyBase cache)
 {
     cache.SetExpires(DateTime.Now.AddMonths(1));
     cache.SetCacheability(HttpCacheability.Public);
     cache.SetValidUntilExpires(true);
 }
コード例 #10
0
ファイル: ncombo.cs プロジェクト: gmoothart/NCombo
 public override void SetResponseCachePolicy(HttpCachePolicyBase cache)
 {
     cache.SetCacheability(HttpCacheability.Public);
     cache.SetExpires(DateTime.Now.AddYears(10));
 }