aspx thread: Problem about the Data Caching Example in QuickStart samples Question Answered
> Origional Question:
> -------------------------------------
>
> Hey Scott,
>
>
http://aspfree.com/quickstart/util/srcview.aspx?path=3D/quickstart/asppl
> us/sam
> ples/cache/datacache2.src
>
>
> I was just running this example in the .net quick start examples.. and
> noticed something that got me curious...
>
> When you insert a new record, at the bottom of the page you get a
> message
> stating the data was accessed from the cache or if it was read
> explicitly
> from the xml file..
>
> So after inserting some data, sometimes the message showed the data
> was got
> from the cache, while other times it said that the data was received
> explicitly. Why is it different at different times?
>
> (1) Can you tell us exactly what happens behind the scenes? If
> possible, I
> want the gory internal details.... :)
>
> (2) How would it be possible to get the data explicitly all the time
> when an
> update is done in the xml file?
>
>
> On a separate note, I downloaded the above code and ran it on my
> machine.
> Same situation. Then I changed the code a bit to try and see what was
> going
> on. Before the "LoadData()" function, I tried to do a "wait" and see
> if the
> cache took sometime to expire. Without realizing it, the code I
> entered in
> was wrong in its syntax.... BUT when I ran the aspx program from my
> browser,
> the code ran without any errors(no browser cache, and data was getting
> inserted!)... only after a few minutes of trying again and again, did
> it
> give me an error. This tells me that the .net runtime, or whatever
> component
> thats responsible to detect a change in the code(would like to know
> what it
> is), did not catch the change! So in essence, the aspx was not
> recompiled
> immediately..
>
> (3) Can you tell us why the above took place and how to fix it?
>
>
> Thanks.
> Girish
>
> ScottGu Answer:
> --------------------------------------
>
> Hi Girish,
>
> Our Cache API allows you to optionally provide a list of files that we
> will automatically monitor for file changes. When changes are made --
> we'll then immediately evict the associated item from the cache --
> allowing programmers to trap this event and re-read the file
> appropriately. The sample you mention above demonstrates how to
> leverage this.
>
> From the error description you provide, I think you are seeing
> problems not because of a bug in ASP.NET -- but rather because of
> client-side browser caching (which is stopping the browser from
> re-hitting the server -- and is instead redisplaying the results from
> a client-side cache). If you hit the "refresh" button this should
> force the browser to go back to the server to get a new version of the
> page. Can you try this to see whether the problem goes away?
>
> If this is the problem, then you probably want to change the cache
> settings you've configured for either your local browser or company
> proxy server.
>
> Hope this helps,
>
> Scott