Mutex page operations

Discussion in 'ASP General' started by Richard Hollis, Dec 12, 2004.

  1. 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
    Richard Hollis, Dec 12, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:%...
    > 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
    >
    >
    Richard Hollis, Dec 14, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jesus M. Salvo Jr.
    Replies:
    2
    Views:
    4,161
    robert
    Feb 11, 2006
  2. NaeiKinDus
    Replies:
    1
    Views:
    572
    Jack Klein
    Apr 14, 2007
  3. NaeiKinDus
    Replies:
    3
    Views:
    606
    James Kanze
    Apr 15, 2007
  4. sven
    Replies:
    2
    Views:
    1,934
    Roy Smith
    Dec 4, 2009
  5. Michael Podolsky
    Replies:
    68
    Views:
    1,075
    Joshua Maurice
    May 10, 2013
Loading...

Share This Page