Simple Xslt extension library - do method results get cached?
Hi,
I've implemented a simple xslt extension library, which is working normally. I've added a method that takes no parameters and returns a string. This gets called from within an xslt template that itself is called twice in the page. So I'd expect the method to get called twice. However, it only gets called once (I've added some log4net logging to it). If I then refresh the page, it doesn't fire at all - so the indication to me is that the results of that method call are being cached - is this possible, and can I turn it off?
That does make a difference that it's an include. Every time you update the included XSLT, you HAVE to touch the XSLT files that are calling it. HAve a look at Doug's comment here. So your problem is probably that you changed the include and didn't re-save the other XSLT file.
I don't think thats the problem though - I forgot to mention I'm working locally on a development machine, and have been restarting IIS to make sure everything is cleared and recompiled. I have also been saving the master xslt because I had read that you need to do this. I just tried again - went through all the xslt files that are used in this page and saved them with some extra whitespace... Still no joy...
I just added the datetime to the string that my method returns, and sure enough what happens is that after the rebuild, the first time umbraco calls the c# method from the xslt it comes back with the current datetime string. But 10 mins later I refresh and the method doesn't get called, and the string is still set to the old (10 mins ago) time...
Alright, sounds good! Well, there's another caching mechanism in Umbraco as well, but you would have to enable it manually. If you go into the macro for this XSLT file, you could specify the caching period for that macro, it should be set to 0 to disable caching. Might that be your problem?
Have realised after much digging, that some of the data is being cached earler in the page lifecycle, and so my xslt isn't firing and having the oppurtunity to call this code. I think a combination of not spotting that and not saving the master xslt pages every time had totally confused me.
Thanks for your help Sebastion, your confirmation that I need to save the master xslt's was helpful for me :)
Ah, the life of a developer, learning to work around our own blind spots! ;-) Glad you're figuring it out! Feel free to ask more questions, there's always plenty of people to help out.
Simple Xslt extension library - do method results get cached?
Hi,
I've implemented a simple xslt extension library, which is working normally. I've added a method that takes no parameters and returns a string. This gets called from within an xslt template that itself is called twice in the page. So I'd expect the method to get called twice. However, it only gets called once (I've added some log4net logging to it). If I then refresh the page, it doesn't fire at all - so the indication to me is that the results of that method call are being cached - is this possible, and can I turn it off?
Here is an example of me calling the method:
<xsl:when test="$currentNode/data[@alias='embedCode'] != ''">
<xsl:variable name="YouTubeUrl" select="Matts.Library:GetYouTubeUrl()" />
....
</xsl:when>
And its plumbed into the xslt here:
xmlns:VisitManchester.Library="urn:Matts.Library"
exclude-result-prefixes="Matts.Library umbraco.library ..">
If it makes a difference, this xslt is in a shared xslt that is included in the master xslt file.
Thanks!
Matt
That does make a difference that it's an include. Every time you update the included XSLT, you HAVE to touch the XSLT files that are calling it. HAve a look at Doug's comment here. So your problem is probably that you changed the include and didn't re-save the other XSLT file.
Sorry, that link should've been to this post: http://forum.umbraco.org/yaf_postst7180_Best-practices-avoiding-duplicate-xslt.aspx
Thanks for the replies Sebastion.
I don't think thats the problem though - I forgot to mention I'm working locally on a development machine, and have been restarting IIS to make sure everything is cleared and recompiled. I have also been saving the master xslt because I had read that you need to do this. I just tried again - went through all the xslt files that are used in this page and saved them with some extra whitespace... Still no joy...
I just added the datetime to the string that my method returns, and sure enough what happens is that after the rebuild, the first time umbraco calls the c# method from the xslt it comes back with the current datetime string. But 10 mins later I refresh and the method doesn't get called, and the string is still set to the old (10 mins ago) time...
Alright, sounds good! Well, there's another caching mechanism in Umbraco as well, but you would have to enable it manually. If you go into the macro for this XSLT file, you could specify the caching period for that macro, it should be set to 0 to disable caching. Might that be your problem?
*Sigh*
Have realised after much digging, that some of the data is being cached earler in the page lifecycle, and so my xslt isn't firing and having the oppurtunity to call this code. I think a combination of not spotting that and not saving the master xslt pages every time had totally confused me.
Thanks for your help Sebastion, your confirmation that I need to save the master xslt's was helpful for me :)
Ah, the life of a developer, learning to work around our own blind spots! ;-) Glad you're figuring it out! Feel free to ask more questions, there's always plenty of people to help out.
Matt,
I am also in preston, fulwood we should get an umbraco meetup going?
Regards
Ismail
is working on a reply...