@@ -178,23 +178,26 @@ public override void OnActionExecuted(HttpActionExecutedContext actionExecutedCo
178178
179179 if ( ! string . IsNullOrWhiteSpace ( cachekey ) && ! ( WebApiCache . Contains ( cachekey ) ) )
180180 {
181- SetEtag ( actionExecutedContext . Response , Guid . NewGuid ( ) . ToString ( ) ) ;
181+ var response = actionExecutedContext . Response ;
182+ var actionContext = actionExecutedContext . ActionContext ;
183+ SetEtag ( response , CreateEtag ( actionExecutedContext , cachekey , cacheTime ) ) ;
182184
183- if ( actionExecutedContext . Response . Content != null )
185+
186+ if ( response . Content != null )
184187 {
185- actionExecutedContext . Response . Content . ReadAsByteArrayAsync ( ) . ContinueWith ( t =>
188+ response . Content . ReadAsByteArrayAsync ( ) . ContinueWith ( t =>
186189 {
187- var baseKey = config . MakeBaseCachekey ( actionExecutedContext . ActionContext . ControllerContext . ControllerDescriptor . ControllerName , actionExecutedContext . ActionContext . ActionDescriptor . ActionName ) ;
190+ var baseKey = config . MakeBaseCachekey ( actionContext . ControllerContext . ControllerDescriptor . ControllerName , actionContext . ActionDescriptor . ActionName ) ;
188191
189192 WebApiCache . Add ( baseKey , string . Empty , cacheTime . AbsoluteExpiration ) ;
190193 WebApiCache . Add ( cachekey , t . Result , cacheTime . AbsoluteExpiration , baseKey ) ;
191194
192195 WebApiCache . Add ( cachekey + Constants . ContentTypeKey ,
193- actionExecutedContext . Response . Content . Headers . ContentType . MediaType ,
196+ response . Content . Headers . ContentType . MediaType ,
194197 cacheTime . AbsoluteExpiration , baseKey ) ;
195198
196199 WebApiCache . Add ( cachekey + Constants . EtagKey ,
197- actionExecutedContext . Response . Headers . ETag . Tag ,
200+ response . Headers . ETag . Tag ,
198201 cacheTime . AbsoluteExpiration , baseKey ) ;
199202 } ) ;
200203 }
@@ -204,6 +207,11 @@ public override void OnActionExecuted(HttpActionExecutedContext actionExecutedCo
204207 ApplyCacheHeaders ( actionExecutedContext . ActionContext . Response , cacheTime ) ;
205208 }
206209
210+ protected virtual string CreateEtag ( HttpActionExecutedContext actionExecutedContext , string cachekey , CacheTime cacheTime )
211+ {
212+ return Guid . NewGuid ( ) . ToString ( ) ;
213+ }
214+
207215 private void ApplyCacheHeaders ( HttpResponseMessage response , CacheTime cacheTime )
208216 {
209217 if ( cacheTime . ClientTimeSpan > TimeSpan . Zero || MustRevalidate || Private )
0 commit comments