My suggestion:
string etag = context.Request.Headers["If-None-Match"];
string modSince = context.Requst.Headers["If-Modified-Since"];
string cacheKey = Constant.AjaxID + ".converter";
CacheInfo ci = context.Cache[cacheKey] as CacheInfo;
if (etag != null && modSince != null && ci != null) {
if (etag == ci.ETag) {
context.Response.StatusCode = 304;
return;
}
else {
try {
DateTime modSinced =
Convert.ToDateTime(modSince).ToUniversalTime();
if(DateTime.Compare(modSinced,
ci.LastModified.ToUniversalTime()) >=
0) {
context.Response.StatusCode = 304;
return;
}
}
catch(Exception) {
if(context.Trace.IsEnabled)
context.Trace.Write(Constant.AjaxID,
"The header value for If-Modified-Since = " + modSince + " could not be
converted to a System.DateTime.");
}
}
}
DateTime lastMod = DateTime.Now;
if (ci == null) {
etag = MD5Helper.GetHash("converter");
context.Cache.Add(Constant.AjaxID + ".converter", new CacheInfo(etag,
lastMod), null,
System.Web.Caching.Cache.NoAbsoluteExpiration,
System.Web.Caching.Cache.NoSlidingExpiration,
System.Web.Caching.CacheItemPriority.Normal, null);
}
else {
etag = ci.ETag;
lastMod = ci.LastModified;
}
context.Response.AddHeader("Content-Type", "application/x-javascript");
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
context.Response.Cache.SetCacheability(System.Web.HttpCacheability.Public);
context.Response.Cache.SetETag(etag);
context.Response.Cache.SetLastModified(lastMod);
// scripts' generating ...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ajax.NET Professional" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/ajaxpro
The latest downloads of Ajax.NET Professional can be found at
http://www.ajaxpro.info
-~----------~----~----~----~------~----~------~--~---