Question

Is it possible to clear the output cache of one asp.net web application from inside another asp.net web application?

Reason being... We have several wep applications structured like...

Pages in /area1/ and /area2/ are cached and are managed through /intranet/cms/. When a page is edited using /intranet/cms/ I want to clear it out of the cache in the appropriate /area#/ application.

I already tried using a VaryByCustom that looks up a guid stored in the HttpContext.Cache but that seems to be cached per web application, that doesn't work.

Really if there were any way of passing data between web applications on a single server, that would solve my problem, since I can use that + VaryByCustom.

Thanks!

-Mike Thomas

Was it helpful?

Solution

The way I've done this in the past is to have a "hidden" page (in each of the /areaX sites) that does the flushing, reloading, etc. The page validates a shared secret query parameter before doing anything (to avoid DoS attacks). If valid the page would output an "OK" message once the operation is complete; generates a 404 error if the secret is invalid.

If you want the flush to be on a per-item or per-group basis then add a second parameter that identifies that item/group.

This method is also server technology independent, and can be triggered by other management tools if required.

OTHER TIPS

One way I know of doing this is by using a shared resource as a dependency, usually a file. When the file is changed, the cache is cleared. I think you can use HttpResponse.AddFileDependency for this.

However, in these cases it's usually better to use an out-of-process cache such as memcached. I haven't tested it myself, but this link deals on using memcached with OutputCache.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top