This sample code below help us to implement loading data with caching support
context.Response.Write(response.ToString());
string version = GetVersion(); //your dynamic version number
context.Response.ContentType = "text/css"; // "text/javascript"
context.Response.AddFileDependencies(files.ToArray());
// define cache info
HttpCachePolicy cache = context.Response.Cache;
cache.SetCacheability(HttpCacheability.Public);
cache.VaryByParams["param"] = true; // cache depend on what parameter
cache.SetETag(version);
cache.SetLastModifiedFromFileDependencies();
cache.SetMaxAge(TimeSpan.FromDays(14));
cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
No comments:
Post a Comment