We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8168
    • 1,118 Posts
    Hi,

    I have a site where I am using getResources to pull some content into view. I am using RAND to make the items pulled random, currently using the snippet uncached e.g. [[!getResources]], so with every page refresh, a new random set of items are displayed... Great... But....

    Is it possible to adapt getResources to set the caching, so that within a session visit, that the RAND call only happens once - e.g. so if I refresh the page, after the first page load, the items remain the same....? Likewise, within the same browsing session, if I move onto another page, then come back to the page where we have the getResources code call - that again, we don't get another random bunch of items, instead, we just render what the first code call got? THEN... on a different session, we make the random call once more to pick the selection for the new session...

    Is this possible?

    Any ideas how????


    Cheers,

    dubbs.
      • 4172
      • 5,888 Posts
      maybe you could take the Session - id or store another random value into the current Session
      And take that value as a scriptProperty for getCache.
      Then wrap the getResources - call with getCache.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 8168
        • 1,118 Posts
        Quote from: Bruno17 at Nov 16, 2015, 03:41 PM
        maybe you could take the Session - id or store another random value into the current Session
        And take that value as a scriptProperty for getCache.
        Then wrap the getResources - call with getCache.

        Thanks Bruno... will have a look into that idea!
          • 8168
          • 1,118 Posts
          Quote from: Bruno17 at Nov 16, 2015, 03:41 PM
          maybe you could take the Session - id or store another random value into the current Session
          And take that value as a scriptProperty for getCache.
          Then wrap the getResources - call with getCache.

          Bruno,

          Any chance of a bit of assistance on this? I have the PHP in a snippet to get the users session ID, I have getCache working and integrated into my getResources call, but not sure on how to hook up the two...???
            • 4172
            • 5,888 Posts
            I think just adding that as a additional scriptProperty to getCache could work

            [[!getCache?
            here go all your properties 
            
            &dummyproperty=`[[!getSessionID]]`
            ]]


            This should create a different cache-file for each different SessionID
            As far, as I know out of my head, getCache uses its properties and the REQUEST to build the hashed cache-filenames
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 8168
              • 1,118 Posts
              Quote from: Bruno17 at Nov 16, 2015, 09:28 PM
              I think just adding that as a additional scriptProperty to getCache could work

              [[!getCache?
              here go all your properties 
              
              &dummyproperty=`[[!getSessionID]]`
              ]]


              This should create a different cache-file for each different SessionID
              As far, as I know out of my head, getCache uses its properties and the REQUEST to build the hashed cache-filenames

              Thanks - so what PHP is in the getSessionID Snippet then? And where you have called the property "dummyproperty" should I be calling that something else? I am not sure I follow the logic here... sorry!

              UPDATE... I don't follow the logic, but it appears to work nonetheless! Thanks Bruno!!!! [ed. note: dubbs last edited this post 8 years, 4 months ago.]