Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt 14 posts 34 karma points
    May 13, 2010 @ 16:35
    Matt
    0

    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

     

  • Sebastiaan Janssen 5045 posts 15477 karma points MVP admin hq
    May 13, 2010 @ 16:43
    Sebastiaan Janssen
    0

    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.

  • Sebastiaan Janssen 5045 posts 15477 karma points MVP admin hq
    May 13, 2010 @ 16:46
  • Matt 14 posts 34 karma points
    May 13, 2010 @ 19:55
    Matt
    0

    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...

  • Matt 14 posts 34 karma points
    May 13, 2010 @ 20:12
    Matt
    0

    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...

     

     

  • Sebastiaan Janssen 5045 posts 15477 karma points MVP admin hq
    May 13, 2010 @ 20:20
    Sebastiaan Janssen
    0

    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?

  • Matt 14 posts 34 karma points
    May 13, 2010 @ 21:34
    Matt
    0

    *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 :)

     

     

  • Sebastiaan Janssen 5045 posts 15477 karma points MVP admin hq
    May 13, 2010 @ 21:43
    Sebastiaan Janssen
    0

    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.

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    May 17, 2010 @ 12:09
    Ismail Mayat
    0

    Matt,

    I am also in preston, fulwood we should get an umbraco meetup going?

    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft