Пример #1
0
 internal string ToHeaderString()
 {
     if (this._varyStar)
     {
         return("*");
     }
     if (this._headers != null)
     {
         StringBuilder s     = new StringBuilder();
         int           index = 0;
         int           size  = this._headers.Size;
         while (index < size)
         {
             object obj2 = this._headers.GetValue(index);
             if (obj2 != null)
             {
                 HttpCachePolicy.AppendValueToHeader(s, (string)obj2);
             }
             index++;
         }
         if (s.Length > 0)
         {
             return(s.ToString());
         }
     }
     return(null);
 }
Пример #2
0
        /*
         * Construct header value string
         */
        internal String ToHeaderString()
        {
            StringBuilder s;
            Object        item;
            int           i, n;

            if (_varyStar)
            {
                return("*");
            }
            else if (_headers != null)
            {
                s = new StringBuilder();

                for (i = 0, n = _headers.Size; i < n; i++)
                {
                    item = _headers.GetValue(i);
                    if (item != null)
                    {
                        HttpCachePolicy.AppendValueToHeader(s, (String)item);
                    }
                }

                if (s.Length > 0)
                {
                    return(s.ToString());
                }
            }

            return(null);
        }
 public HttpCachePolicyWrapper(HttpCachePolicy httpCachePolicy)
 {
     if (httpCachePolicy == null) {
         throw new ArgumentNullException("httpCachePolicy");
     }
     _httpCachePolicy = httpCachePolicy;
 }
 public HttpCachePolicyWrapper(HttpCachePolicy httpCachePolicy)
 {
     if (httpCachePolicy == null)
     {
         throw new ArgumentNullException("httpCachePolicy");
     }
     this._httpCachePolicy = httpCachePolicy;
 }
 public static void SetToBeCached(HttpCachePolicy cache)
 {
     if (AppConfiguration.UseClientCaching)
     {
         cache.SetCacheability(HttpCacheability.Public);
         cache.SetExpires(Midnight);
         cache.SetValidUntilExpires(true);
     }
 }
		private static void SetCache(HttpCachePolicy cache)
		{
			cache.SetCacheability(HttpCacheability.Public);
			cache.VaryByParams[_paramV] = true;
			cache.VaryByParams[_paramFile] = true;
			cache.SetOmitVaryStar(true);
			cache.SetValidUntilExpires(true);
			cache.SetExpires(DateTime.Now.AddYears(2));
			cache.SetLastModified(DateTime.ParseExact(AppConstants.BuildDate,
				_dateFormat, CultureInfo.GetCultureInfo(_usCulture).DateTimeFormat));
		}
 public HttpCachePolicyWrapper(HttpCachePolicy policy)
 {
     Precondition.Require(policy, () => Error.ArgumentNull("policy"));
     _policy = policy;
 }
Пример #8
0
        /// <summary>
        /// Set the response cache headers for WebResource
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="etag"></param>
        private static void SetCachingHeadersForWebResource(HttpCachePolicy cache, int etag)
        {
            cache.VaryByParams["d"] = true;
            cache.VaryByHeaders["Accept-Encoding"] = true;
            cache.SetOmitVaryStar(true);

            // Keep in the client cache for the time configured in the Web.Config
            cache.SetExpires(DateTime.UtcNow.AddDays(Settings.Instance.DaysInCache));
            cache.SetMaxAge(TimeSpan.FromDays(Settings.Instance.DaysInCache));
            cache.SetValidUntilExpires(true);
            cache.SetLastModified(DateTime.UtcNow);

            cache.SetCacheability(HttpCacheability.Public);

            cache.SetETag(string.Concat("\"", etag, "\""));
        }
Пример #9
0
 public override void SetResponseCachePolicy(HttpCachePolicy cache)
 {
     return;
 }
 /// <summary>
 /// Set the response cache headers for WebResource
 /// </summary>
 /// <param name="cache"></param>
 /// <param name="etag"></param>
 /// <param name="maxAge"></param>
 protected static void SetCachingHeadersForWebResource(HttpCachePolicy cache, string etag, TimeSpan maxAge)
 {
     cache.SetCacheability(HttpCacheability.Public);
     cache.VaryByParams["d"] = true;
     cache.SetOmitVaryStar(true);
     cache.SetExpires(DateTime.Now.Add(maxAge));
     cache.SetValidUntilExpires(true);
     cache.VaryByHeaders["Accept-Encoding"] = true;
     cache.SetETag(string.Concat("\"", etag, "\""));
 }
Пример #11
0
 public ResponseCaching()
 {
     _response = HttpContext.Current.Response;
     _cache = _response.Cache;
 }
Пример #12
0
 /// <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(HttpCachePolicy cache)
 {
     cache.SetCacheability(HttpCacheability.NoCache);
     cache.SetNoStore();
     cache.SetExpires(DateTime.MinValue);
 }
Пример #13
0
 static void doCache(HttpCachePolicy cache, bool onClient) {
   if (Machines.doCache) {
     cache.SetCacheability(onClient ? HttpCacheability.Private : HttpCacheability.NoCache);
     cache.SetExpires(DateTime.UtcNow.AddDays(1));
   } else
     cache.SetCacheability(HttpCacheability.NoCache);
 }
Пример #14
0
 public static IHttpCachePolicy Cast(HttpCachePolicy cachePolicy)
 {
     return new HttpCachePolicyProxy(cachePolicy);
 }
Пример #15
0
		// ReSharper disable once UnusedParameter.Local
		private HttpCachePolicyBase ConvertCache(HttpCachePolicy cache)
		{
			return null;
		}
 public HttpCachePolicyWrapper(HttpCachePolicy httpCachePolicy)
 {
 }
Пример #17
0
		/// <summary>
		/// Configures ASP.Net's Cache policy based on properties set
		/// </summary>
		/// <param name="policy">cache policy to set</param>
		void ICachePolicyConfigurer.Configure(HttpCachePolicy policy)
		{
			policy.SetAllowResponseInBrowserHistory(allowInHistory);
			policy.SetCacheability(cacheability);
			policy.SetOmitVaryStar(omitVaryStar);
			policy.SetRevalidation(revalidation);
			policy.SetSlidingExpiration(slidingExpiration);
			policy.SetValidUntilExpires(validUntilExpires);

			if (duration != 0)
			{
				policy.SetExpires(DateTime.Now.AddSeconds(duration));
			}

			if (varyByContentEncodings != null)
			{
				foreach (var header in varyByContentEncodings.Split(','))
				{
					policy.VaryByContentEncodings[header.Trim()] = true;
				}
			}

			if (varyByCustom != null)
			{
				policy.SetVaryByCustom(varyByCustom);
			}

			if (varyByHeaders != null)
			{
				foreach (var header in varyByHeaders.Split(','))
				{
					policy.VaryByHeaders[header.Trim()] = true;
				}
			}

			if (varyByParams != null)
			{
				foreach (var param in varyByParams.Split(','))
				{
					policy.VaryByParams[param.Trim()] = true;
				}
			}

			if (cacheExtension != null)
			{
				policy.AppendCacheExtension(cacheExtension);
			}

			if (setEtagFromFileDependencies)
			{
				policy.SetETagFromFileDependencies();
			}

			if (setLastModifiedFromFileDependencies)
			{
				policy.SetLastModifiedFromFileDependencies();
			}

			if (setNoServerCaching)
			{
				policy.SetNoServerCaching();
			}

			if (setNoStore)
			{
				policy.SetNoStore();
			}

			if (setNoTransforms)
			{
				policy.SetNoTransforms();
			}

			if (etag != null)
			{
				policy.SetETag(etag);
			}

			if (isLastModifiedSet)
			{
				policy.SetLastModified(lastModified);
			}

			if (isMaxAgeSet)
			{
				policy.SetMaxAge(TimeSpan.FromSeconds(maxAge));
			}

			if (isProxyMaxAgeSet)
			{
				policy.SetProxyMaxAge(TimeSpan.FromSeconds(proxyMaxAge));
			}
		}
Пример #18
0
 public HttpCachePolicyProxy(HttpCachePolicy httpCachePolicy)
 {
     _httpCachePolicy = httpCachePolicy;
 }
Пример #19
0
		/// <summary>
		/// Configures ASP.Net's Cache policy based on properties set
		/// </summary>
		/// <param name="policy">cache policy to set</param>
		void ICachePolicyConfigurer.Configure(HttpCachePolicy policy)
		{
			policy.SetCacheability(cacheability);
			policy.SetSlidingExpiration(slidingExpiration);
			policy.SetValidUntilExpires(validUntilExpires);
			policy.SetAllowResponseInBrowserHistory(allowInHistory);
			
			if (duration != 0)
			{
				policy.SetExpires(DateTime.Now.AddSeconds(duration));
			}

			if (varyByCustom != null)
			{
				policy.SetVaryByCustom(varyByCustom);
			}
			
			if (varyByHeaders != null)
			{
				foreach(String header in varyByHeaders.Split(','))
				{
					policy.VaryByHeaders[header.Trim()] = true;
				}
			}

			if (varyByParams != null)
			{
				foreach(String param in varyByParams.Split(','))
				{
					policy.VaryByParams[param.Trim()] = true;
				}
			}

			if (etag != null)
			{
				policy.SetETag(etag);
			}
		}
Пример #20
0
 protected override void SetResponseCachePolicy(HttpCachePolicy cache)
 {
     return;
 }
 public HttpCachePolicyWrapper(HttpCachePolicy httpCachePolicy)
 {
 }