c# - What is better: caching through HttpContext.Current.Cache or just a static? -


Last night I wrote my first IHttpModule for processing some requests. I inspected the raw URL I'm using a regular expression to do this IHttpModule will be called on each request, so caching is a good way to cache some types of regular expression objects to prevent it from being created on every request.

Now my question ... What's the better: To store instant items or to use Private Static Regex in your module, HttpContext.Current. Use Cache ?

I'm looking at the reasons why to just clarify: regex will never change and thus always be the same thing.

If regex isn 't going to change (and this is not usually the case), then:

  Private static readox rijks pattern = new reggae ("...", regedx option compact);   

is the fastest and most efficient way of all

Comments