Last night I wrote my first IHttpModuleto handle some queries. I use a regex to validate the source URL. IHttpModulewill be called for each request, so it seems advisable to do some caching of the regular expression object to prevent it from being created on every request.
Now my question is ... which is better: use HttpContext.Current.Cacheto store the created object or for use private static Regexin my module?
I look forward to the reasons. Just to clarify: the regex will never change and thus will always be the same.
source
share