Mixing server & client http chaching

Hi,
I’m considering if it makes sense to mix server and http client caching in SStack.
Server caching is for dumb clients who do not honour maxage and etg headers
Client caching is for smart clients.

I think that if you keep maxage & server cache duration to the same value it makes sense,
I tried to implement a mix of the 2 approaches in this way

public object Any(CachedOperation request)
{
      var resp = Cache.Get<CachedOperationResponse>(CachedOperationKey);
      if (resp==null)
      {
        resp = new CachedOperationResponse { 
            Pong = request.Ping, ServerTime = DateTime.UtcNow };
        Cache.Set(CachedOperationKey, resp,
         TimeSpan.FromSeconds(_serviceStackCache.ServerCacheDurationInSeconds));
      }
      var ret2 = new HttpResult(resp)
      {
        MaxAge = TimeSpan.FromSeconds(_serviceStackCache.MaxAgeInSeconds),
        CacheControl = CacheControl.Private,
        ETag = _serviceStackCache.EtagEnabled ? getETag(resp) : null
      };
      return ret2;
}

Looking at fiddler traffc, it seems to me that everything is working as expected (but for the fact that if a server returns a cookie the asp.net stack for cache-control to private drops maxage setting)
Do you think this approach has any drawback ?
Thank you
enrico

You can, but if you’re going to use both Server and HTTP Caching I’d just be using the [CacheResponse] attribute, e.g:

[CacheResponse(Duration=60, MaxAge=30)]
public object Any(CachedOperation request) => new CachedOperationResponse { 
    Pong = request.Ping, ServerTime = DateTime.UtcNow };

I don’t really see what all that extra boilerplate buys you.

As you stated in a previous post, one cannot handle Etags through the CacheResponse attribute

My example doesn’t use ETags which I wouldn’t use with Server caching.