By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,289 Members | 3,049 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,289 IT Pros & Developers. It's quick & easy.

Application Cache question

P: n/a
Hi

The following code works on my develeopment machine using the VS web server.
When I run the application on 2 other Windows 2003/IIS 6 servers no caching
seems to take place at all. Can someone explain what I might be doing wrong
or what to look out for? What's the differece between IIS and VS web server?
The IIS servers seem to have enough memory.

public DataTable GetAll()
{
DataTable dt;

// try to retrieve item from cache
dt = (DataTable)_context.Cache[_cacheKeyName];

if (dt == null)
{
dt = tableAdapter.GetAll();
_context.Cache.Insert(_cacheKeyName, dt, null, Cache.NoAbsoluteExpiration,
TimeSpan.FromSeconds(600));
}
return dt;
}
Many thanks

Andrew
Sep 3 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Andrew,

From your description, you have an ASP.NET 2.0 application which use cache
to store objects. You found the application work fine on dev machine(in VS
2005 Test server) but can not persist cache on product server(win2k3 iis),
correct?

Based on the code snippet you provided, I think the code logic should be
correct and as you mentioned it work on dev machine, therefore, the problem
is likely due to the deployment environment. Of course, there is no
particular limitation on Application cache between IIS hosted and VS 2005
test server enviornment. Would you tried the following things to further
simplify the issue?

** Create a new empty project and add a simple page to dedicated on using
cache to store objects(you can try both small objects and large objects)

** In the windows performance counters, you can add the ASP.NET cache
related counters(such as "CACHE API Entries" ) under the "ASP.NET APPs
V2.0....." category.

If the problem can be even reproted through such as simple project, it will
make the problem much clearer.

If you have any other finding, please also feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
>From: "J055" <j0**@newsgroups.nospam>
Subject: Application Cache question
Date: Mon, 3 Sep 2007 20:11:53 +0100
Hi

The following code works on my develeopment machine using the VS web
server.
>When I run the application on 2 other Windows 2003/IIS 6 servers no
caching
>seems to take place at all. Can someone explain what I might be doing
wrong
>or what to look out for? What's the differece between IIS and VS web
server?
>The IIS servers seem to have enough memory.

public DataTable GetAll()
{
DataTable dt;

// try to retrieve item from cache
dt = (DataTable)_context.Cache[_cacheKeyName];

if (dt == null)
{
dt = tableAdapter.GetAll();
_context.Cache.Insert(_cacheKeyName, dt, null,
Cache.NoAbsoluteExpiration,
>TimeSpan.FromSeconds(600));
}
return dt;
}
Many thanks

Andrew
Sep 4 '07 #2

P: n/a
Hi Steven

I can see that small objects seem to work. It doesn't really help me because
on the development machine large objects work too.

On the main server that seems to be having problems I watched some of the
performance counters you suggested. The object I'm attempting to cache is a
Dictionary<int, stringwith around 20 entries.

Cache API Entries: 0 - 2 (mostly 0)
Cache API Hit Ratio: 51.638
Cache API Hits: 268
Cache API Misses: 251

I'm afraid though that I have no idea how to interpret these figures. Does
it suggest anything to you?

Thanks again
Andrew

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:0z**************@TK2MSFTNGHUB02.phx.gbl...
Hi Andrew,

From your description, you have an ASP.NET 2.0 application which use cache
to store objects. You found the application work fine on dev machine(in VS
2005 Test server) but can not persist cache on product server(win2k3 iis),
correct?

Based on the code snippet you provided, I think the code logic should be
correct and as you mentioned it work on dev machine, therefore, the
problem
is likely due to the deployment environment. Of course, there is no
particular limitation on Application cache between IIS hosted and VS 2005
test server enviornment. Would you tried the following things to further
simplify the issue?

** Create a new empty project and add a simple page to dedicated on using
cache to store objects(you can try both small objects and large objects)

** In the windows performance counters, you can add the ASP.NET cache
related counters(such as "CACHE API Entries" ) under the "ASP.NET APPs
V2.0....." category.

If the problem can be even reproted through such as simple project, it
will
make the problem much clearer.

If you have any other finding, please also feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
>>From: "J055" <j0**@newsgroups.nospam>
Subject: Application Cache question
Date: Mon, 3 Sep 2007 20:11:53 +0100
Hi

The following code works on my develeopment machine using the VS web
server.
>>When I run the application on 2 other Windows 2003/IIS 6 servers no
caching
>>seems to take place at all. Can someone explain what I might be doing
wrong
>>or what to look out for? What's the differece between IIS and VS web
server?
>>The IIS servers seem to have enough memory.

public DataTable GetAll()
{
DataTable dt;

// try to retrieve item from cache
dt = (DataTable)_context.Cache[_cacheKeyName];

if (dt == null)
{
dt = tableAdapter.GetAll();
_context.Cache.Insert(_cacheKeyName, dt, null,
Cache.NoAbsoluteExpiration,
>>TimeSpan.FromSeconds(600));
}
return dt;
}
Many thanks

Andrew

Sep 5 '07 #3

P: n/a
Hi

I've done a little more research. I understand the counter stats better now.
I checked the data being retrieved from SQL Server and it's around 15,000
Bytes (133 rows), it gets pulled into a DataTable then a Dictionary. I guess
that has little to do with why the caching doesn't work so well.

The settings are to use sliding expiration for 5 minutes. Even though the
hit ratio is 50% (which I think is bad anyway), the cache seems to be
cleared almost immediately most of the time.

When I recycle the IIS App pool the cache seems to work better for a few
minutes and then degrades again shortly after.

I'd like to cache a lot more objeects in the application but I need to
undertstand what this problem is first. Any ideas?

Thanks
Andrew
Sep 6 '07 #4

P: n/a
Thanks for your reply Andrew,

Yes, for the counters, the "CACHE API Entries" can help indicate the cache
items added the user(exclude the ones added by system), you can check it to
see whether the number matches the items your code have added.

As you said the DataTable object is around 15,000 Bytes, is your
application frequently caching such objects? If so, it may produce some
memory pressure. You can have a look at the EventLog to see whether there
is entry indicate the ASP.NET worker process has recycled frequently or
whether the ASP.NET application is restarting constantly. Application
Restart may cause the Cache objects lost. BTW, is it possible to repro
the same problem through a very simple project with a single page to cache
some large datatables(you may use code to manually create some datatable
objects for test). If so, you can also send me the project and let me
perform some local test.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "J055" <j0**@newsgroups.nospam>
References: <ef**************@TK2MSFTNGP03.phx.gbl>
<0z**************@TK2MSFTNGHUB02.phx.gbl>
<#A**************@TK2MSFTNGP04.phx.gbl>
>Subject: Re: Application Cache question
Date: Thu, 6 Sep 2007 12:59:39 +0100
>
Hi

I've done a little more research. I understand the counter stats better
now.
>I checked the data being retrieved from SQL Server and it's around 15,000
Bytes (133 rows), it gets pulled into a DataTable then a Dictionary. I
guess
>that has little to do with why the caching doesn't work so well.

The settings are to use sliding expiration for 5 minutes. Even though the
hit ratio is 50% (which I think is bad anyway), the cache seems to be
cleared almost immediately most of the time.

When I recycle the IIS App pool the cache seems to work better for a few
minutes and then degrades again shortly after.

I'd like to cache a lot more objeects in the application but I need to
undertstand what this problem is first. Any ideas?

Thanks
Andrew
Sep 7 '07 #5

P: n/a
Hi Andrew,

Have you got any progress on this? I'm still monitoring on this issue and
would like to check the issue status with you.

Also, based on the nature of this problem, it may not be quite easy and
efficient to troubleshoot through newsgroup communication. Therefore, if
this is an urgent issue, I would suggest you consider contact CSS phone
support directly. Anyway, if you need continual help from us, please feel
free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Organization: Microsoft
Date: Fri, 07 Sep 2007 03:33:59 GMT
Subject: Re: Application Cache question
>Lines: 55
Path: TK2MSFTNGHUB02.phx.gbl
Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.dotnet.framework.aspnet:41489
NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122

Thanks for your reply Andrew,

Yes, for the counters, the "CACHE API Entries" can help indicate the cache
items added the user(exclude the ones added by system), you can check it
to
>see whether the number matches the items your code have added.

As you said the DataTable object is around 15,000 Bytes, is your
application frequently caching such objects? If so, it may produce some
memory pressure. You can have a look at the EventLog to see whether there
is entry indicate the ASP.NET worker process has recycled frequently or
whether the ASP.NET application is restarting constantly. Application
Restart may cause the Cache objects lost. BTW, is it possible to repro
the same problem through a very simple project with a single page to cache
some large datatables(you may use code to manually create some datatable
objects for test). If so, you can also send me the project and let me
perform some local test.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>>From: "J055" <j0**@newsgroups.nospam>
References: <ef**************@TK2MSFTNGP03.phx.gbl>
<0z**************@TK2MSFTNGHUB02.phx.gbl>
<#A**************@TK2MSFTNGP04.phx.gbl>
>>Subject: Re: Application Cache question
Date: Thu, 6 Sep 2007 12:59:39 +0100
>>
Hi

I've done a little more research. I understand the counter stats better
now.
>>I checked the data being retrieved from SQL Server and it's around 15,000
Bytes (133 rows), it gets pulled into a DataTable then a Dictionary. I
guess
>>that has little to do with why the caching doesn't work so well.

The settings are to use sliding expiration for 5 minutes. Even though the
hit ratio is 50% (which I think is bad anyway), the cache seems to be
cleared almost immediately most of the time.

When I recycle the IIS App pool the cache seems to work better for a few
minutes and then degrades again shortly after.

I'd like to cache a lot more objeects in the application but I need to
undertstand what this problem is first. Any ideas?

Thanks
Andrew

Sep 11 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.