Example #1
0
 public void HandleEvent(EntityDeleted <LocaleStringResource> eventMessage)
 {
     if (eventMessage.Entity.ResourceName.StartsWith("qa.", true, ci))
     {
         EditorGlobal.GenerateEtag(eventMessage.Entity.Language.LanguageCulture);
     }
 }
Example #2
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            HttpRequestBase request  = filterContext.HttpContext.Request;
            string          language = EngineContext.Current.Resolve <IWorkContext>().WorkingLanguage.LanguageCulture;

            //string eTag = request.Headers["ETag"];
            string eTag = request.Headers["If-None-Match"];
            string responseEtag;

            EditorGlobal.CurrentEtag.TryGetValue(language, out responseEtag);

            if (string.IsNullOrEmpty(responseEtag))
            {
                EditorGlobal.GenerateEtag(language);
                responseEtag = EditorGlobal.CurrentEtag[language];
            }

            HttpResponseBase response = filterContext.HttpContext.Response;

            if (!string.IsNullOrEmpty(eTag))
            {
                if (eTag.Equals(responseEtag))
                {
                    response.StatusCode        = 304;
                    response.StatusDescription = "Not Modified";
                    response.Cache.SetETag(responseEtag);
                    return;
                }
            }

            response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate);
            //response.AddHeader("ETag", responseETag);
            response.Cache.SetETag(responseEtag);
        }