I am attempting to write a http module that will apply some cache settings depending on what is being requested. We want to allow clients to cache certain resources for an extended period without revalidating. The relevant code looks like this:
if (HttpContext.Current.Handler.GetType().FullName == "System.Web.StaticFileHandler" &&
CacheBustedResourceRegex.IsMatch(request.RawUrl))
{
_log.DebugFormat(
"Explicitly allow caching on '{0}'. Max age is {1}",
request.RawUrl,
MaxAgeForCacheBustedResources);
response.Cache.SetCacheability(HttpCacheability.Public);
response.Cache.SetMaxAge(MaxAgeForCacheBustedResources);
}
However, for static files, HttpContext.Current.Handler is null during the PostMapRequestHandler, PostRequestHandlerExecute, and PreRequestHandlerExecute events. Is there any way to discern static files from others? I ...
Go to the complete details ...