Request.Cookies and web application performance

Request.Cookies and web application performance

am 15.01.2008 05:06:03 von ekovnatsky

Our web application is a site that gets thousands and thousands of
hits daily. So obviously in such multi-threaded environment
performance is important. The ASP frontend is written the way that
each time a value of a certain cookie is needed a call to
request.cookies("cookieName") is executed.
Question - does anyone know if executing this call is a costly
operation or not? Purely from the performance standpoint does it make
sense to execute this call once, save its value in a variable and then
use this variable rather than calling request.cookies all the time? I
could not find a definitive answer online.
Just FYI it is not ASP.NET and the IIS server version is 6.0.
Thanks in advance
Eugene

Re: Request.Cookies and web application performance

am 15.01.2008 10:21:59 von Anthony Jones

wrote in message
news:4cceb3a9-0241-4871-afe3-8295e24c76a5@s19g2000prg.google groups.com...
> Our web application is a site that gets thousands and thousands of
> hits daily. So obviously in such multi-threaded environment
> performance is important. The ASP frontend is written the way that
> each time a value of a certain cookie is needed a call to
> request.cookies("cookieName") is executed.
> Question - does anyone know if executing this call is a costly
> operation or not? Purely from the performance standpoint does it make
> sense to execute this call once, save its value in a variable and then
> use this variable rather than calling request.cookies all the time? I
> could not find a definitive answer online.
> Just FYI it is not ASP.NET and the IIS server version is 6.0.

Using Request.Cookies will cost more than simply using a variable. The
Cookies property supplies a dictionary implementation.

Since a single cookie my itself be a multivalued item a call such as:-

Request.Cookies("cookieName")

returns an object that also follows the dictionary pattern.

This object (an implementation of an interface a called IReadCookie) has a
default item property that has an optional parameter. Use of

Request.Cookies("cookieName")

where an object is not expected is actually

Request.Cookies.Item("cookieName").Item()

All of this is going to be somewhat more costly than simply retrieving a
value from a variable.

That said unless use of cookies extraordinarily extensive and pervasive
across your more often visited pages I doubt your would see a perceptible
difference by elimination multiple calls. However certainly you would want
to remove them from any potentially long running loops.

--
Anthony Jones - MVP ASP/ASP.NET