I have a site which is using caching for some frequently used pages. When
the page-level cache expires, or is expired by me, the page will get
re-rendered to a static HTML file and then shown to the user, after it has
been rendered.

Assume the cache is stale. Somebody comes along and requests the page. It
will then get re-generated, but whilst this is happening, if somebody comes
along and requests the page again then they can get an error because the
static HTML page file is still being recreated by the previous page request.

What I think I need is a mutex for the page to stop this from happening,
for the second page request, during cache refresh. So: 1st request owns the
mutex until finished, and, whilst it's updating, all other page requests
wait on the mutex.

How can I implement a 'mutex' style operation for this scenario in ASP or
handle it better to avoid this situation from happening? I've got my code
able to understand if the page being requested is actually being updated, so
I could just redirect the client back to the same script again, but at the
same time the update process itself takes less than a second, so if the page
could somehow wait for the operation to complete it would be a cleaner
operation. I tried wrapping the Sleep API in a COM object, but this didn't
seem to work and I'm just looking for a bit of a sanity check on the best
way to go about this.

Thanks
Richard

Re: Mutex page operations by Richard

Richard
Tue Dec 14 01:40:03 CST 2004

Solution: SleepEx API in wrapper COM object and a short wait time, with a
timeout period inside the ASP include script. Sleep API won't work for some
reason.

"Richard Hollis" <richard_hollis@hotmail.com> wrote in message
news:%23l9AuEK4EHA.2624@TK2MSFTNGP10.phx.gbl...
> I have a site which is using caching for some frequently used pages. When
> the page-level cache expires, or is expired by me, the page will get
> re-rendered to a static HTML file and then shown to the user, after it has
> been rendered.
>
> Assume the cache is stale. Somebody comes along and requests the page.
It
> will then get re-generated, but whilst this is happening, if somebody
comes
> along and requests the page again then they can get an error because the
> static HTML page file is still being recreated by the previous page
request.
>
> What I think I need is a mutex for the page to stop this from happening,
> for the second page request, during cache refresh. So: 1st request owns
the
> mutex until finished, and, whilst it's updating, all other page requests
> wait on the mutex.
>
> How can I implement a 'mutex' style operation for this scenario in ASP or
> handle it better to avoid this situation from happening? I've got my code
> able to understand if the page being requested is actually being updated,
so
> I could just redirect the client back to the same script again, but at the
> same time the update process itself takes less than a second, so if the
page
> could somehow wait for the operation to complete it would be a cleaner
> operation. I tried wrapping the Sleep API in a COM object, but this
didn't
> seem to work and I'm just looking for a bit of a sanity check on the best
> way to go about this.
>
> Thanks
> Richard
>
>