I'm using the GetXmlDocumentByURL extension and passing in a cache time.
I'm finding that sometimes the XML document returned isn't correct (maybe a server error or some other error) but this is being cached so that all subsequent requests get this garbled XML document.
What I'd like is to be able to clear the cached XML from the XSLT. Is this possible?
I'm also looking into IIS output caching - maybe this would be a better way to handle this?
In case anyone else is interested, I've also investigated IIS output caching but it doesn't seem to work with Umbraco. You can't use the @OutputCache declaration - I think its something to do with the way umbraco renders templates (I've read how it does not work properly with master pages).
For anyone interested, I've written an XSLT extension that can clear any cached macro or page cached by getxmldoc. I'll make a package some time but heres the code:
using System; using System.Collections.Generic; using System.Web;
namespace cacheClearer { public class cacheClearer {
public static void clearGetXmlDocByURLCache(string url) { string Key = "GetXmlDoc_" + url; if (System.Web.HttpRuntime.Cache[Key] != null) { System.Web.HttpRuntime.Cache.Remove(Key); } }
public static void clearMacroCache(string macroNodeId) { string Key = "umbMacro" + macroNodeId; if (System.Web.HttpRuntime.Cache[Key] != null) { System.Web.HttpRuntime.Cache.Remove(Key); } }
GetXmlDocumentByUrl and caching
Hi,
I'm using the GetXmlDocumentByURL extension and passing in a cache time.
I'm finding that sometimes the XML document returned isn't correct (maybe a server error or some other error) but this is being cached so that all subsequent requests get this garbled XML document.
What I'd like is to be able to clear the cached XML from the XSLT. Is this possible?
I'm also looking into IIS output caching - maybe this would be a better way to handle this?
Thanks!
it's possible if you write a small xslt extension or some inline script to clear the cache
All you need to do is call:
(either from xslt extension or through some inline script code -> I'd take the second approach as this is only a single line of code)
Cheers,
/Dirk
That sounds perfect - thank you.
How do I know what the key is though?
Anyone know anything about how to get the key?
In case anyone else is interested, I've also investigated IIS output caching but it doesn't seem to work with Umbraco. You can't use the @OutputCache declaration - I think its something to do with the way umbraco renders templates (I've read how it does not work properly with master pages).
Edward,
Found some references in the core code :p
and
Hope this helps.
Regards,
/Dirk
Thats great - thanks Dirk!
For anyone interested, I've written an XSLT extension that can clear any cached macro or page cached by getxmldoc. I'll make a package some time but heres the code:
using System;
using System.Collections.Generic;
using System.Web;
namespace cacheClearer
{
public class cacheClearer
{
public static void clearGetXmlDocByURLCache(string url)
{
string Key = "GetXmlDoc_" + url;
if (System.Web.HttpRuntime.Cache[Key] != null)
{
System.Web.HttpRuntime.Cache.Remove(Key);
}
}
public static void clearMacroCache(string macroNodeId)
{
string Key = "umbMacro" + macroNodeId;
if (System.Web.HttpRuntime.Cache[Key] != null)
{
System.Web.HttpRuntime.Cache.Remove(Key);
}
}
}
}
is working on a reply...