473,385 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Controling cache expiration

Hi all.

I keep my ViewState in server's cache. Works fine except when user leaves
the page opened for a long time (2 hours or so). Then if he/she tries to
post it back the server throws an exception saying that ViewState was
invalid. I suspect it has something to do with cache expiration time. Can I
control its expiration time from within my web.config? Or anyhow? Couldn't
find anything related in web or machine config files or documentation :(

Just in case: I set all ViewState cache entries with CacheItemPriority.High;
I write and read ViewState to/from the hard drive if an entry gets removed
(expires) from cache (implementing CacheItemRemovedCallback delegate) - and
it looks like it only works on my local machine, files never appear on
production server and I don't see any exception logs explaining why files
were not written to the drive; I would keep ViewState in the Session object
(I suppose it would work more reliably) but I had to create my own session
object (some of my users are scared of any kind of cookies, imagine that),
so the cache is my only choice.

Any kind of help, or related articles, or thoughts would be highly
appreciated!!
Kikoz.
Nov 19 '05 #1
2 1961
I assume you are defining user specific cache keys for storing the viewstate
in the cache, and also manually removing it when not required anymore. If
this is the case, ensure your code is not inadvertently removing incorrect
items (or ones that dont apply to that user).

Also, the CacheItemPriority enumeration supports a NotRemovable option to
prevent it being removed from the cache when freeing system resources.

--

- Paul Glavich
ASP.NET MVP
ASPInsider (www.aspinsiders.com)
"Kikoz" <ki***@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
Hi all.

I keep my ViewState in server's cache. Works fine except when user leaves
the page opened for a long time (2 hours or so). Then if he/she tries to
post it back the server throws an exception saying that ViewState was
invalid. I suspect it has something to do with cache expiration time. Can I control its expiration time from within my web.config? Or anyhow? Couldn't
find anything related in web or machine config files or documentation :(

Just in case: I set all ViewState cache entries with CacheItemPriority.High; I write and read ViewState to/from the hard drive if an entry gets removed
(expires) from cache (implementing CacheItemRemovedCallback delegate) - and it looks like it only works on my local machine, files never appear on
production server and I don't see any exception logs explaining why files
were not written to the drive; I would keep ViewState in the Session object (I suppose it would work more reliably) but I had to create my own session
object (some of my users are scared of any kind of cookies, imagine that),
so the cache is my only choice.

Any kind of help, or related articles, or thoughts would be highly
appreciated!!
Kikoz.

Nov 19 '05 #2
Yes, I use user-specific cache keys for each http request (a combination of
custom session variable and requested url, to be exact). I don't remove
entries manually, leaving it to the garbage collector - Cache.Insert allows
to set expiration and call back on removal (supposedly). This is why I'm
trying to use call back to flush entry that is being removed (expired) to the
disk - to preserve the ViewState even if memory gets full. And apparently it
doesn't work. I'm afraid to set entries as NotRemovable because it's a
hosting shared environment with 2 GB memory on the server, so me and other
200+ applications that are on the same disk(s) can fill that up quickly
before entries will expire if we all would have lots of requests at the same
time.

Still looking for answer. Please help, guys :)
Kikoz.

"Paul Glavich [MVP ASP.NET]" wrote:
I assume you are defining user specific cache keys for storing the viewstate
in the cache, and also manually removing it when not required anymore. If
this is the case, ensure your code is not inadvertently removing incorrect
items (or ones that dont apply to that user).

Also, the CacheItemPriority enumeration supports a NotRemovable option to
prevent it being removed from the cache when freeing system resources.

--

- Paul Glavich
ASP.NET MVP
ASPInsider (www.aspinsiders.com)
"Kikoz" <ki***@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
Hi all.

I keep my ViewState in server's cache. Works fine except when user leaves
the page opened for a long time (2 hours or so). Then if he/she tries to
post it back the server throws an exception saying that ViewState was
invalid. I suspect it has something to do with cache expiration time. Can

I
control its expiration time from within my web.config? Or anyhow? Couldn't
find anything related in web or machine config files or documentation :(

Just in case: I set all ViewState cache entries with

CacheItemPriority.High;
I write and read ViewState to/from the hard drive if an entry gets removed
(expires) from cache (implementing CacheItemRemovedCallback delegate) -

and
it looks like it only works on my local machine, files never appear on
production server and I don't see any exception logs explaining why files
were not written to the drive; I would keep ViewState in the Session

object
(I suppose it would work more reliably) but I had to create my own session
object (some of my users are scared of any kind of cookies, imagine that),
so the cache is my only choice.

Any kind of help, or related articles, or thoughts would be highly
appreciated!!
Kikoz.


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joe Fallon | last post by:
I am trying to setup a cache that refreshes itself every hour. (My sample code is for every minute so I can test it.) I have found some examples that I thought worked but they all seem to fail....
2
by: Dicky Cheng | last post by:
Hi, I am using absolute expiration to expire my cache object in Cache API. And I set it to expire after 60min. Then I test it, it cache, and everything fine. Then I stop working and lock...
1
by: Guadala Harry | last post by:
AFAIK, when placing an object into the Cache with no special instructions (no dependencies, sliding expirations, hard expirations, etc), it will just sit there in the Cache until the system decides...
3
by: MattC | last post by:
Hi, I am persisting the viewstate for each page into the Cache object, below is shown my methods for saving and loading: I am able to save the viewstate to the cache and most times I can load...
4
by: Diffident | last post by:
Hello All, I inserted an object into cache with absolute expiration using the following code: DateTime AbsoluteExpirationDate = DateRangesForDataLists.AddDays(1); //Expires the next day...
2
by: sternr | last post by:
Hey, (Sorry if the thread has been posted twice!) I'm using the System.Web.Caching.Cache object in my Win App and basically, it's great! I use a sliding expiration TimeStamp to the object I put...
2
by: =?Utf-8?B?Y2F0?= | last post by:
We recently moved an older ASP.NET 1.1 code base on to ASP.NET 2.0, .NET 3.0 and Windows 2003 Server SP2. We started experiencing the following issue with the web cache (the code is straightforward...
4
by: Jordan S. | last post by:
Using .NET 3.5... When I add an item to the system Cache, like this: HttpRuntime.Cache = "Some string"; For how long will it remain in the Cache by default. Could it remain there,...
5
by: =?Utf-8?B?Y2hlY2tyYWlzZXJAY29tbXVuaXR5Lm5vc3BhbQ== | last post by:
I have a site which I secure with forms authentication. When the user's sign on and hit one of the secure pages, I have this line in my code to ensure that the browser does not cache the page;...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.