Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void SetResponseCachePolicy(string filePath,HttpResponse response) {
- #if DEBUG
- bool IsDebug = true;
- #else
- bool IsDebug = false;
- #endif
- if(IsDebug) {
- response.Cache.SetCacheability(HttpCacheability.NoCache);
- }
- else {
- HttpCachePolicy cachePolicy = response.Cache;
- string etag = Math.Abs(filePath.GetHashCode()).ToString();
- cachePolicy.SetCacheability(HttpCacheability.Public);
- cachePolicy.SetOmitVaryStar(true);
- cachePolicy.SetExpires(DateTime.Now.AddDays(730));
- cachePolicy.SetValidUntilExpires(true);
- cachePolicy.SetLastModifiedFromFileDependencies();
- cachePolicy.SetETag(etag);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment