Showing posts with label cache. Show all posts
Showing posts with label cache. Show all posts

Monday, March 26, 2012

Newbie: Page level caching in ASP.NET

Hi,
How could Page level caching be implemented in ASP.NET ? My ASP.NET page
takes some query arguments and I want page level cache to last for the
lifetime of the page generated using the passed arguments only. If different
arguments are passed, I want new page level cache for the new page. Is it as
simple as adding page level variables ? Note page may query data
asynchronously using AJAX also. Does it change things ?
Thanks and regards
NavinAjax shouldn't screw around with anything.
To cache different versions based on querystring values, use the VaryByParam
attribute of the OutputCache control
<%@. OutputCache Duration="3600" VaryByParam="id" %>
assuming "id" is the querystring you want to create a different cache on.
Take a look at:
http://samples.gotdotnet.com/quicks...putcaching.aspx
Karl
MY ASP.Net tutorials
http://www.openmymind.net/
"Navin Mishra" <navin.mishra@.siemens.com> wrote in message
news:uQ6LgmEAGHA.916@.TK2MSFTNGP10.phx.gbl...
> Hi,
> How could Page level caching be implemented in ASP.NET ? My ASP.NET page
> takes some query arguments and I want page level cache to last for the
> lifetime of the page generated using the passed arguments only. If
> different
> arguments are passed, I want new page level cache for the new page. Is it
> as
> simple as adding page level variables ? Note page may query data
> asynchronously using AJAX also. Does it change things ?
> Thanks and regards
> Navin
>
Thanks. My qyery string is long passing a bunch of arguments. Would it work
for a combination of query string arguments ? Is there a limit ? I also
wanted simple caching while generated page is active and, to use the cache,
when an action is performed on the page. When page is destroyed, I want to
clear THAT page level cache. Would simple page level variables do that are
garbage collected when Page object is destroyed after ASP.NET page request
completes ?
Thanks again and regards
"Karl Seguin" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uwpW89EAGHA.1256@.TK2MSFTNGP15.phx.gbl...
> Ajax shouldn't screw around with anything.
> To cache different versions based on querystring values, use the
VaryByParam
> attribute of the OutputCache control
> <%@. OutputCache Duration="3600" VaryByParam="id" %>
> assuming "id" is the querystring you want to create a different cache on.
> Take a look at:
> http://samples.gotdotnet.com/quicks...putcaching.aspx
> Karl
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
> "Navin Mishra" <navin.mishra@.siemens.com> wrote in message
> news:uQ6LgmEAGHA.916@.TK2MSFTNGP10.phx.gbl...
page
it
>
Comments appreciated! Is it possible ?
Thanks in advance and regards
"Navin Mishra" <navin.mishra@.siemens.com> wrote in message
news:%231jq8DLAGHA.3984@.TK2MSFTNGP14.phx.gbl...
> Thanks. My qyery string is long passing a bunch of arguments. Would it
work
> for a combination of query string arguments ? Is there a limit ? I also
> wanted simple caching while generated page is active and, to use the
cache,
> when an action is performed on the page. When page is destroyed, I want to
> clear THAT page level cache. Would simple page level variables do that are
> garbage collected when Page object is destroyed after ASP.NET page request
> completes ?
> Thanks again and regards
> "Karl Seguin" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net>
> wrote in message news:uwpW89EAGHA.1256@.TK2MSFTNGP15.phx.gbl...
> VaryByParam
on.
> page
> it
>

Saturday, March 24, 2012

Newbie: Questions about Cache object

Hi,
I'm trying to use Cache object for the first item. I've some questions
about that:
(1) Should Add, Remove and Insert method calls need to be synchronized ?
(2) Is it possible to add a cache dependency for cascading deletes i.e. if
cache key A is removed(based on time based expiration), so is key B which is
depnedent on it ?
Thanks in advance and regards
Navin1) If you want to be absolutely threadsafe using the Cache, use the Lock
keyword in your insert etc. methods.
2) Cascading deletes from the cache should be easy to implement using the
CacheItemRemovedCallback delegate , where in the callback target for item A
you would go ahead and remove Item B.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Navin Mishra" wrote:

> Hi,
> I'm trying to use Cache object for the first item. I've some questions
> about that:
> (1) Should Add, Remove and Insert method calls need to be synchronized ?
> (2) Is it possible to add a cache dependency for cascading deletes i.e. if
> cache key A is removed(based on time based expiration), so is key B which
is
> depnedent on it ?
> Thanks in advance and regards
> Navin
>
>
Thanks for quick response. For (2), is there any example ? In callback, how
I access the Cache object as it is part og request context ? Can a key item
dependency be used instead ?
Thanks again and regards
"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.nospammin.com> wrote in message
news:CA9F6ABA-FF0B-40EA-BAB2-D2077B90670C@.microsoft.com...
> 1) If you want to be absolutely threadsafe using the Cache, use the Lock
> keyword in your insert etc. methods.
> 2) Cascading deletes from the cache should be easy to implement using the
> CacheItemRemovedCallback delegate , where in the callback target for item
A
> you would go ahead and remove Item B.
> Peter
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
> "Navin Mishra" wrote:
>
if
which is

Newbie: Questions about Cache object

Hi,

I'm trying to use Cache object for the first item. I've some questions
about that:

(1) Should Add, Remove and Insert method calls need to be synchronized ?
(2) Is it possible to add a cache dependency for cascading deletes i.e. if
cache key A is removed(based on time based expiration), so is key B which is
depnedent on it ?

Thanks in advance and regards

Navin1) If you want to be absolutely threadsafe using the Cache, use the Lock
keyword in your insert etc. methods.

2) Cascading deletes from the cache should be easy to implement using the
CacheItemRemovedCallback delegate , where in the callback target for item A
you would go ahead and remove Item B.

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com

"Navin Mishra" wrote:

> Hi,
> I'm trying to use Cache object for the first item. I've some questions
> about that:
> (1) Should Add, Remove and Insert method calls need to be synchronized ?
> (2) Is it possible to add a cache dependency for cascading deletes i.e. if
> cache key A is removed(based on time based expiration), so is key B which is
> depnedent on it ?
> Thanks in advance and regards
> Navin
>
Thanks for quick response. For (2), is there any example ? In callback, how
I access the Cache object as it is part og request context ? Can a key item
dependency be used instead ?

Thanks again and regards

"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.nospammin.com> wrote in message
news:CA9F6ABA-FF0B-40EA-BAB2-D2077B90670C@.microsoft.com...
> 1) If you want to be absolutely threadsafe using the Cache, use the Lock
> keyword in your insert etc. methods.
> 2) Cascading deletes from the cache should be easy to implement using the
> CacheItemRemovedCallback delegate , where in the callback target for item
A
> you would go ahead and remove Item B.
> Peter
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
> "Navin Mishra" wrote:
> > Hi,
> > I'm trying to use Cache object for the first item. I've some questions
> > about that:
> > (1) Should Add, Remove and Insert method calls need to be synchronized ?
> > (2) Is it possible to add a cache dependency for cascading deletes i.e.
if
> > cache key A is removed(based on time based expiration), so is key B
which is
> > depnedent on it ?
> > Thanks in advance and regards
> > Navin