i have an application that cache pages with output cache directive of asp.net.
When i insert update or delete somthing from the control panel i want to reset the output cache.
Locally my algorithm works great.
When i run it on share host, cache doesn’t clear.
my algorithm is very straight forward :
In global.asax i init a list with all the pages that i use output cache.
OutputCacheHelper.Directories.Add(OutputCacheHelper.AllPagesKey, new List<string>() {
"/Default.aspx",
"/pages/DisplayContactForm.aspx",
"/pages/PhotosGallery.aspx",
"/pages/Schedule.aspx",
"/pages/Shows.aspx",
"/pages/cms/DisplayCategory.aspx",
"/pages/cms/DisplayCategoryAlternative.aspx",
"/pages/cms/DisplayFrontPage.aspx",
"/pages/cms/ViewAirstaff.aspx",
"/pages/cms/ViewArticle.aspx",
"/pages/cms/ViewShow.aspx"
});
Then whenever i insert/update/delete data from the database i use the above algorithm :
foreach (string directory in Directories[AllPagesKey])
{
HttpResponse.RemoveOutputCacheItem(directory);
}
I don’t know why this don’t work on shared hosting.
Please help.
Thank you and sorry for my english.
EDIT
Sorry for the delay.
I was on a business trip.
I figure it out…
Not as i want but i can apply only output cache.
(because Azure is not available)
I add a dependance on a file and then when i want to clear the cache, i just chage the content.
Is it ok?
Your shared hosting is a single server or a server farm (like AZURE)?
Cache is a server-level, so in a multi-instance context, clearing cache on an istance doesn’t effect cache on other servers.
EDIT
In multi-server context you can:
-use shared cache (AZURE provides it but it costs money)
–create a system that manages cache (ie use a DB table to store last update time for each object, so that any server before look into cache knoes if it has to be resetted)
–avoid using cache