private static string GetCacheControlValueString(HttpCachePolicyBehavior behavior)
        {
            var cacheControlStr = new StringBuilder();

            if (behavior.CacheControlMode == CacheControlModes.NoControl ||
                behavior.CacheControlMode == CacheControlModes.UseExpires)
            {
                return(behavior.CacheControlCustom);
            }

            if (behavior.CacheControlMode == CacheControlModes.DisableCache)
            {
                cacheControlStr.Append("no-cache, no-store, must-revalidate,");
            }

            if (behavior.CacheControlMode == CacheControlModes.UseMaxAge)
            {
                cacheControlStr.AppendFormat("max-age={0},", behavior.CacheControlMaxAge.TotalSeconds);
            }

            cacheControlStr.Append(behavior.CacheControlCustom);
            if (cacheControlStr.Length > 0 &&
                cacheControlStr[cacheControlStr.Length - 1] == ',')
            {
                cacheControlStr.Remove(cacheControlStr.Length - 1, 1);
            }

            return(cacheControlStr.ToString());
        }
        protected override object CreateBehavior()
        {
            var behavior = new HttpCachePolicyBehavior
            {
                CacheControlMode   = CacheControlMode,
                CacheControlMaxAge = CacheControlMaxAge,
                HttpExpires        = HttpExpires,
                CacheControlCustom = CacheControlCustom
            };

            return(behavior);
        }
 public HttpCachePolicyMessageInspector(HttpCachePolicyBehavior behavior)
 {
     _behavior = behavior;
 }