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