473,512 Members | 14,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Caching to an Application Variable, and Performance Issues

Hi, I couldn't find what I was looking for by searching the newsgroup, but perhaps these have already been discussed somewhere. This is a bit long with a lot of interrelated questions.

What I've got is a decodeImage.aspx page that gets called to decode base64 encoded images and return them as displayable images to a Web page. The ASPX page is passed two parameters, "file" and "img". The "file" parameter specifies and XML file on the Web server that contains data including base64 encoded images. The "img" parameter specifies an index to identify which image should be encoded and returned. There could be any number of images to be decoded in the XML file, and their size is also uncertain.

My concern is that if a particular page calls this decodeImage.aspx page numerous times that I am wasting valuable time and efforts by having the XML file loaded each and every time. If I am wrong and this file is not reloaded each time, please let me know, but it's my understanding it will be loaded each time.

So what I was thinking was to cache as an Application variable in the XmlNodeList that was populated with a call to SelectNodes, and name the variable based on the "file" parameter. Then if I find that the variable already exists, use the cached object instead of reloading. Since these images are used site wide, I didn't think a Session variable was appropriate. There can be any number of XML files used, so there could be any number of Application variables that need to be set.

That seems fairly straightforward, but I have a few concerns with that:
1. Can I store the XmlNodeList object and restore it for use the next time?
a. If not, is there any advantage to storing the XML in the variable over having it reloaded?
2. What is the max size for an Application variable?
3. What is the max size for all Application variables together?
4. What actually happens when that size limit has been reached?
5. Once each image have been decoded, are they cached on the server for the Web page to use, or will the Web page always and forever call in to redecode the image each time?
a. If so, I'd like to know my alternatives.
b. If not, how do I know when to release that variable?
6. How do I find out when the XML file has been updated so that I know to update the Application variable?

I think that about covers it. If I think of anything else related to this scenario, I'll do a followup post.

Thanks ahead of time for your help!

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

Nov 18 '05 #1
7 2150
Hi Greg,

1. Can I store the XmlNodeList object and restore it for use the next time?
a. If not, is there any advantage to storing the XML in the variable
over having it reloaded?

The Application and Application Cache are Collections, pure and simple.
Well, the Cache is a specialized type of Collection, but it is, underneath
the specialization (extra methods, fields, etc) a Collection. They are, in
essence, Name and Object Collections.

As everything in .Net is an object, you can store anything in these
Collections, and use them just as you would any object in any Collection.

The advantage of storing your XML in the Collection is the saving of IO
processing and the processing involved in reading the XML from the file into
an object. So, yes, there is an advantage in terms of performance.

2. What is the max size for an Application variable?

AFAIK, there is no maximum size, other than memory capacity. At least, I've
never run into one. And I have put a LOT of data in the Cache before (dozens
of MB).

3. What is the max size for all Application variables together?

Same as above.

4. What actually happens when that size limit has been reached?

I would imagine an "out of memory" exception, but that's just a guess.

5. Once each image have been decoded, are they cached on the server for the
Web page to use, or will the Web page always and forever call in to redecode
the image each time?
a. If so, I'd like to know my alternatives.
b. If not, how do I know when to release that variable?

If you put them into a Collection, such as Application or Cache, they are
cached. How do you know when to release that variable? Well, it's not a
variable, it's a member object of a Collection. Using the Cache, you can
tell the Cache when to remove the object, or you can remove it yourself. If
these XML documents are needed for the lifetime of the Application, you can
do that as well. No harm done. When the Application ends, the Collection is
automatically released.

6. How do I find out when the XML file has been updated so that I know to
update the Application variable?

You could use a FileSystemWatcher to watch for changes in the folder
containing the files, and have it respond to them. You could even cache the
FileSystemWatcher, so that it resides in the Application and works for the
lifetime of the Application.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Greg Collins [MVP]" <Greg.Collins_AT_InfoPathDev.com> wrote in message
news:#l**************@tk2msftngp13.phx.gbl...
Hi, I couldn't find what I was looking for by searching the newsgroup, but
perhaps these have already been discussed somewhere. This is a bit long with
a lot of interrelated questions.

What I've got is a decodeImage.aspx page that gets called to decode base64
encoded images and return them as displayable images to a Web page. The ASPX
page is passed two parameters, "file" and "img". The "file" parameter
specifies and XML file on the Web server that contains data including base64
encoded images. The "img" parameter specifies an index to identify which
image should be encoded and returned. There could be any number of images to
be decoded in the XML file, and their size is also uncertain.

My concern is that if a particular page calls this decodeImage.aspx page
numerous times that I am wasting valuable time and efforts by having the XML
file loaded each and every time. If I am wrong and this file is not reloaded
each time, please let me know, but it's my understanding it will be loaded
each time.

So what I was thinking was to cache as an Application variable in the
XmlNodeList that was populated with a call to SelectNodes, and name the
variable based on the "file" parameter. Then if I find that the variable
already exists, use the cached object instead of reloading. Since these
images are used site wide, I didn't think a Session variable was
appropriate. There can be any number of XML files used, so there could be
any number of Application variables that need to be set.

That seems fairly straightforward, but I have a few concerns with that:
1. Can I store the XmlNodeList object and restore it for use the next time?
a. If not, is there any advantage to storing the XML in the variable
over having it reloaded?
2. What is the max size for an Application variable?
3. What is the max size for all Application variables together?
4. What actually happens when that size limit has been reached?
5. Once each image have been decoded, are they cached on the server for the
Web page to use, or will the Web page always and forever call in to redecode
the image each time?
a. If so, I'd like to know my alternatives.
b. If not, how do I know when to release that variable?
6. How do I find out when the XML file has been updated so that I know to
update the Application variable?

I think that about covers it. If I think of anything else related to this
scenario, I'll do a followup post.

Thanks ahead of time for your help!

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com


Nov 18 '05 #2
see inline >> comments:

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
| Hi Greg,
|
| 1. Can I store the XmlNodeList object and restore it for use the next
time?
| a. If not, is there any advantage to storing the XML in the variable
| over having it reloaded?
|
| The Application and Application Cache are Collections, pure and simple.
| Well, the Cache is a specialized type of Collection, but it is, underneath
| the specialization (extra methods, fields, etc) a Collection. They are, in
| essence, Name and Object Collections.
there is one difference between the application cache and the application collections.
if memory usage gets high, entries in the cache will automatically be
removed.

|
| As everything in .Net is an object, you can store anything in these
| Collections, and use them just as you would any object in any Collection.
|
| The advantage of storing your XML in the Collection is the saving of IO
| processing and the processing involved in reading the XML from the file
into
| an object. So, yes, there is an advantage in terms of performance.
|
| 2. What is the max size for an Application variable?
|
| AFAIK, there is no maximum size, other than memory capacity. At least,
I've
| never run into one. And I have put a LOT of data in the Cache before
(dozens
| of MB).
|
| 3. What is the max size for all Application variables together?
|
| Same as above.
see below
|
| 4. What actually happens when that size limit has been reached?
|
| I would imagine an "out of memory" exception, but that's just a guess.
if you look in machine.config/web.config, there is a setting for the max amount of memory asp.net will use (usually 60% of real memory). if asp.net
goes over this number, its recycled (this will lose inproc sessions).

|
| 5. Once each image have been decoded, are they cached on the server for
the
| Web page to use, or will the Web page always and forever call in to
redecode
| the image each time?
| a. If so, I'd like to know my alternatives.
| b. If not, how do I know when to release that variable?
|
| If you put them into a Collection, such as Application or Cache, they are
| cached. How do you know when to release that variable? Well, it's not a
| variable, it's a member object of a Collection. Using the Cache, you can
| tell the Cache when to remove the object, or you can remove it yourself.
If
| these XML documents are needed for the lifetime of the Application, you
can
| do that as well. No harm done. When the Application ends, the Collection
is
| automatically released.
|
| 6. How do I find out when the XML file has been updated so that I know to
| update the Application variable?
|
| You could use a FileSystemWatcher to watch for changes in the folder
| containing the files, and have it respond to them. You could even cache
the
| FileSystemWatcher, so that it resides in the Application and works for the
| lifetime of the Application.
|
if you use the application cache object you can place a cache dependency

on the file, and the cache will release the object automatically if the file
is changed.
| --
| HTH,
| Kevin Spencer
| .Net Developer
| Microsoft MVP
| I get paid good money to
| solve puzzles for a living
|
| "Greg Collins [MVP]" <Greg.Collins_AT_InfoPathDev.com> wrote in message
| news:#l**************@tk2msftngp13.phx.gbl...
| Hi, I couldn't find what I was looking for by searching the newsgroup, but
| perhaps these have already been discussed somewhere. This is a bit long
with
| a lot of interrelated questions.
|
| What I've got is a decodeImage.aspx page that gets called to decode base64
| encoded images and return them as displayable images to a Web page. The
ASPX
| page is passed two parameters, "file" and "img". The "file" parameter
| specifies and XML file on the Web server that contains data including
base64
| encoded images. The "img" parameter specifies an index to identify which
| image should be encoded and returned. There could be any number of images
to
| be decoded in the XML file, and their size is also uncertain.
|
| My concern is that if a particular page calls this decodeImage.aspx page
| numerous times that I am wasting valuable time and efforts by having the
XML
| file loaded each and every time. If I am wrong and this file is not
reloaded
| each time, please let me know, but it's my understanding it will be loaded
| each time.
|
| So what I was thinking was to cache as an Application variable in the
| XmlNodeList that was populated with a call to SelectNodes, and name the
| variable based on the "file" parameter. Then if I find that the variable
| already exists, use the cached object instead of reloading. Since these
| images are used site wide, I didn't think a Session variable was
| appropriate. There can be any number of XML files used, so there could be
| any number of Application variables that need to be set.
|
| That seems fairly straightforward, but I have a few concerns with that:
| 1. Can I store the XmlNodeList object and restore it for use the next
time?
| a. If not, is there any advantage to storing the XML in the variable
| over having it reloaded?
| 2. What is the max size for an Application variable?
| 3. What is the max size for all Application variables together?
| 4. What actually happens when that size limit has been reached?
| 5. Once each image have been decoded, are they cached on the server for
the
| Web page to use, or will the Web page always and forever call in to
redecode
| the image each time?
| a. If so, I'd like to know my alternatives.
| b. If not, how do I know when to release that variable?
| 6. How do I find out when the XML file has been updated so that I know to
| update the Application variable?
|
| I think that about covers it. If I think of anything else related to this
| scenario, I'll do a followup post.
|
| Thanks ahead of time for your help!
|
| --
| Greg Collins [InfoPath MVP]
| Please visit: http://www.InfoPathDev.com
|
|
|
|
Nov 18 '05 #3
So if I understand you both correctly I could do the following (please excuse my lack of .NET experience and correct anything you need to):

1. The first time the decodeImage.aspx page is hit for a particular XML file, decode the entire list of images, placing each one into an array which is then stored in an Application Cache object in the Cache Collection. This object can be named and referenced using the absolute path of the URL to the XML file being decoded (minus any forbidden characters).

2. I can somehow create a link between the Application Cache object and the XML file itself so that when the XML file is modified, the Cache object is automatically removed from the Collection, thus signaling me to reload the file, decode the images again, and recreate the Cache object.

3. Any subsequent requests for an image would grab the appropriate image from the image array Cache object and return it to the calling Web page.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
========================================
1. Can I store the XmlNodeList object and restore it for use the next time?
a. If not, is there any advantage to storing the XML in the variable over having it reloaded?

---KEVIN---------------------------
The Application and Application Cache are Collections, pure and simple. Well, the Cache is a specialized type of Collection, but it is, underneath the specialization (extra methods, fields, etc) a Collection. They are, in essence, Name and Object Collections.

As everything in .Net is an object, you can store anything in these Collections, and use them just as you would any object in any Collection.

The advantage of storing your XML in the Collection is the saving of IO processing and the processing involved in reading the XML from the file into an object. So, yes, there is an advantage in terms of performance.

---BRUCE---------------------------
there is one difference between the application cache and the application collections. if memory usage gets high, entries in the cache will automatically be removed.
========================================
2. What is the max size for an Application variable?

---KEVIN---------------------------
AFAIK, there is no maximum size, other than memory capacity. At least, I've never run into one. And I have put a LOT of data in the Cache before (dozens of MB).
========================================
4. What actually happens when that size limit has been reached?

---KEVIN---------------------------
I would imagine an "out of memory" exception, but that's just a guess.

---BRUCE---------------------------
if you look in machine.config/web.config, there is a setting for the max amount of memory asp.net will use (usually 60% of real memory). if asp.net goes over this number, its recycled (this will lose inproc sessions).
========================================
5. Once each image have been decoded, are they cached on the server for the Web page to use, or will the Web page always and forever call in to redecode the image each time?
a. If so, I'd like to know my alternatives.
b. If not, how do I know when to release that variable?
---KEVIN---------------------------
If you put them into a Collection, such as Application or Cache, they are cached. How do you know when to release that variable? Well, it's not a variable, it's a member object of a Collection. Using the Cache, you can tell the Cache when to remove the object, or you can remove it yourself.

If these XML documents are needed for the lifetime of the Application, you can do that as well. No harm done. When the Application ends, the Collection is automatically released.
========================================
6. How do I find out when the XML file has been updated so that I know to update the Application variable?
---KEVIN---------------------------
You could use a FileSystemWatcher to watch for changes in the folder containing the files, and have it respond to them. You could even cache the FileSystemWatcher, so that it resides in the Application and works for the lifetime of the Application.

---BRUCE---------------------------
If you use the application cache object you can place a cache dependency on the file, and the cache will release the object automatically if the file is changed.

Nov 18 '05 #4
Those steps seemed to work. I have it all implemented and working as I described!

Thank you all for your help! I might not have been able to do it without your knowledge and suggestions!

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

"Greg Collins [MVP]" <Greg.Collins_AT_InfoPathDev.com> wrote in message news:#V**************@TK2MSFTNGP09.phx.gbl...
So if I understand you both correctly I could do the following (please excuse my lack of .NET experience and correct anything you need to):

1. The first time the decodeImage.aspx page is hit for a particular XML file, decode the entire list of images, placing each one into an array which is then stored in an Application Cache object in the Cache Collection. This object can be named and referenced using the absolute path of the URL to the XML file being decoded (minus any forbidden characters).

2. I can somehow create a link between the Application Cache object and the XML file itself so that when the XML file is modified, the Cache object is automatically removed from the Collection, thus signaling me to reload the file, decode the images again, and recreate the Cache object.

3. Any subsequent requests for an image would grab the appropriate image from the image array Cache object and return it to the calling Web page.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
========================================
1. Can I store the XmlNodeList object and restore it for use the next time?
a. If not, is there any advantage to storing the XML in the variable over having it reloaded?

---KEVIN---------------------------
The Application and Application Cache are Collections, pure and simple. Well, the Cache is a specialized type of Collection, but it is, underneath the specialization (extra methods, fields, etc) a Collection. They are, in essence, Name and Object Collections.

As everything in .Net is an object, you can store anything in these Collections, and use them just as you would any object in any Collection.

The advantage of storing your XML in the Collection is the saving of IO processing and the processing involved in reading the XML from the file into an object. So, yes, there is an advantage in terms of performance.

---BRUCE---------------------------
there is one difference between the application cache and the application collections. if memory usage gets high, entries in the cache will automatically be removed.
========================================
2. What is the max size for an Application variable?

---KEVIN---------------------------
AFAIK, there is no maximum size, other than memory capacity. At least, I've never run into one. And I have put a LOT of data in the Cache before (dozens of MB).
========================================
4. What actually happens when that size limit has been reached?

---KEVIN---------------------------
I would imagine an "out of memory" exception, but that's just a guess.

---BRUCE---------------------------
if you look in machine.config/web.config, there is a setting for the max amount of memory asp.net will use (usually 60% of real memory). if asp.net goes over this number, its recycled (this will lose inproc sessions).
========================================
5. Once each image have been decoded, are they cached on the server for the Web page to use, or will the Web page always and forever call in to redecode the image each time?
a. If so, I'd like to know my alternatives.
b. If not, how do I know when to release that variable?
---KEVIN---------------------------
If you put them into a Collection, such as Application or Cache, they are cached. How do you know when to release that variable? Well, it's not a variable, it's a member object of a Collection. Using the Cache, you can tell the Cache when to remove the object, or you can remove it yourself.

If these XML documents are needed for the lifetime of the Application, you can do that as well. No harm done. When the Application ends, the Collection is automatically released.
========================================
6. How do I find out when the XML file has been updated so that I know to update the Application variable?
---KEVIN---------------------------
You could use a FileSystemWatcher to watch for changes in the folder containing the files, and have it respond to them. You could even cache the FileSystemWatcher, so that it resides in the Application and works for the lifetime of the Application.

---BRUCE---------------------------
If you use the application cache object you can place a cache dependency on the file, and the cache will release the object automatically if the file is changed.

Nov 18 '05 #5
Yes. I would use a cahe dependency, as bruce suggested. If you do, you don't
want to store all the SML files as a single array. You would cache each
individually. If the file changes, the cached object is removed. You would
therefore have to include code that checks to see whether the particular XML
file is cached before attempting to get it. If it is cached, it is fetched
from the cache. If not, the file is opened, parsed, and put into the cache,
and THEN it is fectched from the cache.

I would also recommend that you only cache each XML file as needed, since
they will be removed individually, and must be replaced individually. IOW,
wait until you receive a request for a given XML file prior to caching that
one file.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Greg Collins [MVP]" <Greg.Collins_AT_InfoPathDev.com> wrote in message
news:#V**************@TK2MSFTNGP09.phx.gbl...
So if I understand you both correctly I could do the following (please
excuse my lack of .NET experience and correct anything you need to):

1. The first time the decodeImage.aspx page is hit for a particular XML
file, decode the entire list of images, placing each one into an array which
is then stored in an Application Cache object in the Cache Collection. This
object can be named and referenced using the absolute path of the URL to the
XML file being decoded (minus any forbidden characters).

2. I can somehow create a link between the Application Cache object and the
XML file itself so that when the XML file is modified, the Cache object is
automatically removed from the Collection, thus signaling me to reload the
file, decode the images again, and recreate the Cache object.

3. Any subsequent requests for an image would grab the appropriate image
from the image array Cache object and return it to the calling Web page.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
========================================
1. Can I store the XmlNodeList object and restore it for use the next time?
a. If not, is there any advantage to storing the XML in the variable
over having it reloaded?

---KEVIN---------------------------
The Application and Application Cache are Collections, pure and simple.
Well, the Cache is a specialized type of Collection, but it is, underneath
the specialization (extra methods, fields, etc) a Collection. They are, in
essence, Name and Object Collections.

As everything in .Net is an object, you can store anything in these
Collections, and use them just as you would any object in any Collection.

The advantage of storing your XML in the Collection is the saving of IO
processing and the processing involved in reading the XML from the file into
an object. So, yes, there is an advantage in terms of performance.

---BRUCE---------------------------
there is one difference between the application cache and the application
collections. if memory usage gets high, entries in the cache will
automatically be removed.
========================================
2. What is the max size for an Application variable?

---KEVIN---------------------------
AFAIK, there is no maximum size, other than memory capacity. At least, I've
never run into one. And I have put a LOT of data in the Cache before (dozens
of MB).
========================================
4. What actually happens when that size limit has been reached?

---KEVIN---------------------------
I would imagine an "out of memory" exception, but that's just a guess.

---BRUCE---------------------------
if you look in machine.config/web.config, there is a setting for the max
amount of memory asp.net will use (usually 60% of real memory). if asp.net
goes over this number, its recycled (this will lose inproc sessions).
========================================
5. Once each image have been decoded, are they cached on the server for the
Web page to use, or will the Web page always and forever call in to redecode
the image each time?
a. If so, I'd like to know my alternatives.
b. If not, how do I know when to release that variable?
---KEVIN---------------------------
If you put them into a Collection, such as Application or Cache, they are
cached. How do you know when to release that variable? Well, it's not a
variable, it's a member object of a Collection. Using the Cache, you can
tell the Cache when to remove the object, or you can remove it yourself.

If these XML documents are needed for the lifetime of the Application, you
can do that as well. No harm done. When the Application ends, the Collection
is automatically released.
========================================
6. How do I find out when the XML file has been updated so that I know to
update the Application variable?
---KEVIN---------------------------
You could use a FileSystemWatcher to watch for changes in the folder
containing the files, and have it respond to them. You could even cache the
FileSystemWatcher, so that it resides in the Application and works for the
lifetime of the Application.

---BRUCE---------------------------
If you use the application cache object you can place a cache dependency on
the file, and the cache will release the object automatically if the file is
changed.
Nov 18 '05 #6
Yep! Right on top of that one! I had the same thoughts!

Thanx for sharing that info... it helps a lot! And it makes me feel like I'm actually starting to understand a little of this.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

"Kevin Spencer" <ks******@takempis.com> wrote in message news:OA**************@TK2MSFTNGP15.phx.gbl...
Yes. I would use a cahe dependency, as bruce suggested. If you do, you don't
want to store all the SML files as a single array. You would cache each
individually. If the file changes, the cached object is removed. You would
therefore have to include code that checks to see whether the particular XML
file is cached before attempting to get it. If it is cached, it is fetched
from the cache. If not, the file is opened, parsed, and put into the cache,
and THEN it is fectched from the cache.

I would also recommend that you only cache each XML file as needed, since
they will be removed individually, and must be replaced individually. IOW,
wait until you receive a request for a given XML file prior to caching that
one file.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Greg Collins [MVP]" <Greg.Collins_AT_InfoPathDev.com> wrote in message
news:#V**************@TK2MSFTNGP09.phx.gbl...
So if I understand you both correctly I could do the following (please
excuse my lack of .NET experience and correct anything you need to):

1. The first time the decodeImage.aspx page is hit for a particular XML
file, decode the entire list of images, placing each one into an array which
is then stored in an Application Cache object in the Cache Collection. This
object can be named and referenced using the absolute path of the URL to the
XML file being decoded (minus any forbidden characters).

2. I can somehow create a link between the Application Cache object and the
XML file itself so that when the XML file is modified, the Cache object is
automatically removed from the Collection, thus signaling me to reload the
file, decode the images again, and recreate the Cache object.

3. Any subsequent requests for an image would grab the appropriate image
from the image array Cache object and return it to the calling Web page.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
========================================
1. Can I store the XmlNodeList object and restore it for use the next time?
a. If not, is there any advantage to storing the XML in the variable
over having it reloaded?

---KEVIN---------------------------
The Application and Application Cache are Collections, pure and simple.
Well, the Cache is a specialized type of Collection, but it is, underneath
the specialization (extra methods, fields, etc) a Collection. They are, in
essence, Name and Object Collections.

As everything in .Net is an object, you can store anything in these
Collections, and use them just as you would any object in any Collection.

The advantage of storing your XML in the Collection is the saving of IO
processing and the processing involved in reading the XML from the file into
an object. So, yes, there is an advantage in terms of performance.

---BRUCE---------------------------
there is one difference between the application cache and the application
collections. if memory usage gets high, entries in the cache will
automatically be removed.
========================================
2. What is the max size for an Application variable?

---KEVIN---------------------------
AFAIK, there is no maximum size, other than memory capacity. At least, I've
never run into one. And I have put a LOT of data in the Cache before (dozens
of MB).
========================================
4. What actually happens when that size limit has been reached?

---KEVIN---------------------------
I would imagine an "out of memory" exception, but that's just a guess.

---BRUCE---------------------------
if you look in machine.config/web.config, there is a setting for the max
amount of memory asp.net will use (usually 60% of real memory). if asp.net
goes over this number, its recycled (this will lose inproc sessions).
========================================
5. Once each image have been decoded, are they cached on the server for the
Web page to use, or will the Web page always and forever call in to redecode
the image each time?
a. If so, I'd like to know my alternatives.
b. If not, how do I know when to release that variable?
---KEVIN---------------------------
If you put them into a Collection, such as Application or Cache, they are
cached. How do you know when to release that variable? Well, it's not a
variable, it's a member object of a Collection. Using the Cache, you can
tell the Cache when to remove the object, or you can remove it yourself.

If these XML documents are needed for the lifetime of the Application, you
can do that as well. No harm done. When the Application ends, the Collection
is automatically released.
========================================
6. How do I find out when the XML file has been updated so that I know to
update the Application variable?
---KEVIN---------------------------
You could use a FileSystemWatcher to watch for changes in the folder
containing the files, and have it respond to them. You could even cache the
FileSystemWatcher, so that it resides in the Application and works for the
lifetime of the Application.

---BRUCE---------------------------
If you use the application cache object you can place a cache dependency on
the file, and the cache will release the object automatically if the file is
changed.
Nov 18 '05 #7
Actually I do have a question. I think I know the answer, but I need to be absolutely sure.

Currently I'm using Cache.Insert() -- Is this an Application level or Session level Cache? As far as I can tell there's only 1 Cache object and it's Application level, but if I'm misguided on that, I want to make sure I'm using the Application Cache and not the Session Cache.

Thanx again in advance!

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

"Kevin Spencer" <ks******@takempis.com> wrote in message news:OA**************@TK2MSFTNGP15.phx.gbl...
Yes. I would use a cahe dependency, as bruce suggested. If you do, you don't
want to store all the SML files as a single array. You would cache each
individually. If the file changes, the cached object is removed. You would
therefore have to include code that checks to see whether the particular XML
file is cached before attempting to get it. If it is cached, it is fetched
from the cache. If not, the file is opened, parsed, and put into the cache,
and THEN it is fectched from the cache.

I would also recommend that you only cache each XML file as needed, since
they will be removed individually, and must be replaced individually. IOW,
wait until you receive a request for a given XML file prior to caching that
one file.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Greg Collins [MVP]" <Greg.Collins_AT_InfoPathDev.com> wrote in message
news:#V**************@TK2MSFTNGP09.phx.gbl...
So if I understand you both correctly I could do the following (please
excuse my lack of .NET experience and correct anything you need to):

1. The first time the decodeImage.aspx page is hit for a particular XML
file, decode the entire list of images, placing each one into an array which
is then stored in an Application Cache object in the Cache Collection. This
object can be named and referenced using the absolute path of the URL to the
XML file being decoded (minus any forbidden characters).

2. I can somehow create a link between the Application Cache object and the
XML file itself so that when the XML file is modified, the Cache object is
automatically removed from the Collection, thus signaling me to reload the
file, decode the images again, and recreate the Cache object.

3. Any subsequent requests for an image would grab the appropriate image
from the image array Cache object and return it to the calling Web page.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
========================================
1. Can I store the XmlNodeList object and restore it for use the next time?
a. If not, is there any advantage to storing the XML in the variable
over having it reloaded?

---KEVIN---------------------------
The Application and Application Cache are Collections, pure and simple.
Well, the Cache is a specialized type of Collection, but it is, underneath
the specialization (extra methods, fields, etc) a Collection. They are, in
essence, Name and Object Collections.

As everything in .Net is an object, you can store anything in these
Collections, and use them just as you would any object in any Collection.

The advantage of storing your XML in the Collection is the saving of IO
processing and the processing involved in reading the XML from the file into
an object. So, yes, there is an advantage in terms of performance.

---BRUCE---------------------------
there is one difference between the application cache and the application
collections. if memory usage gets high, entries in the cache will
automatically be removed.
========================================
2. What is the max size for an Application variable?

---KEVIN---------------------------
AFAIK, there is no maximum size, other than memory capacity. At least, I've
never run into one. And I have put a LOT of data in the Cache before (dozens
of MB).
========================================
4. What actually happens when that size limit has been reached?

---KEVIN---------------------------
I would imagine an "out of memory" exception, but that's just a guess.

---BRUCE---------------------------
if you look in machine.config/web.config, there is a setting for the max
amount of memory asp.net will use (usually 60% of real memory). if asp.net
goes over this number, its recycled (this will lose inproc sessions).
========================================
5. Once each image have been decoded, are they cached on the server for the
Web page to use, or will the Web page always and forever call in to redecode
the image each time?
a. If so, I'd like to know my alternatives.
b. If not, how do I know when to release that variable?
---KEVIN---------------------------
If you put them into a Collection, such as Application or Cache, they are
cached. How do you know when to release that variable? Well, it's not a
variable, it's a member object of a Collection. Using the Cache, you can
tell the Cache when to remove the object, or you can remove it yourself.

If these XML documents are needed for the lifetime of the Application, you
can do that as well. No harm done. When the Application ends, the Collection
is automatically released.
========================================
6. How do I find out when the XML file has been updated so that I know to
update the Application variable?
---KEVIN---------------------------
You could use a FileSystemWatcher to watch for changes in the folder
containing the files, and have it respond to them. You could even cache the
FileSystemWatcher, so that it resides in the Application and works for the
lifetime of the Application.

---BRUCE---------------------------
If you use the application cache object you can place a cache dependency on
the file, and the cache will release the object automatically if the file is
changed.
Nov 18 '05 #8

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

Similar topics

5
2775
by: David Gagné | last post by:
Hi, I'm using ASP on Windows 2K. I'm NOT using ASP.Net. I have static data in an XML file that I would like to cache. Based on my idea explained below, is it an approach that should scale...
1
5063
by: Duncan Welch | last post by:
I'm creating a new C# app to mirror a legacy ASP app. I've created a data access layer (DAL) which uses the singleton model to "emulate" the old Application Variable caching except as a...
6
1550
by: kevin | last post by:
Could someone explain, Caching. I understand Caching as simply saving a copy of something that is unlikely to change and to which you frequently refer as opposed to retrieving a fresh copy every...
4
2713
by: DylanM | last post by:
I've seen a few examples on how to cache data in a WinForms GUI, just after some thought on the best solution. The data I'm trying to cache will be generally be small collections of Business...
17
3224
by: Fred Nelson | last post by:
Hi: I have written several web applications that obtain their connection strings from the web.config file. This is very easy to use and it makes it easy to move an app from development into...
5
7829
by: Raj | last post by:
What is the purpose of file system caching while creating a tablespace? Memory on the test server gets used up pretty quickly after a user executes a complex query(database is already activated),...
6
6245
by: onnodb | last post by:
Hi all, While working on an Access UI to a MySQL database (which should be a reasonable, low-cost, flexible interface to the DB, better than web-based, much less costly than a full-fledged .NET...
4
2166
by: Henrik Dahl | last post by:
Hello! In my application I have a need for using a regular expression now and then. Often the same regular expression must be used multiple times. For performance reasons I use the...
6
1389
by: Phil Sandler | last post by:
All, I am designing a system that will involve an IIS/ASP.Net application server. The main purpose of the application server will be to load large amounts of static data into memory and do fast...
0
7254
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,...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7519
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.