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

    i can not make sense from hiding elements from a certain category for anonymous users.
    i did these steps: http://rtfm.modx.com/display/revolution20/Restricting+an+Element+from+Users

    and when i clear the cache and reload, it does not show up in safari (logged out), but in chrome (logged in), as wished.

    but then i go into the chunk, do some changes and save, and the chunk shows up in safari as well.
    ... until i empty the cache again.

    that does not make sense to me ...

    for that short moment between saving the discussed chunk and clearing the cache the chunk is visible for all users. a bug, or am i doing sth terribly wrong?

    in general, i used access controls quite sometimes now, but i haven’t completey wrapped my head their behaviour.

    thanks,
    niklas
    • So you’re trying to hide elements from anonymous users in the front-end?

      Are you calling the chunk uncached? If you don’t it will be cached the way it is viewed the first time.

      I know my way around the security system as well, but had that same behavior without intending it causing my website to be template-less on pages I didn’t visit from the manager yet. Couldn’t reproduce it (it all worked for me!) but would keep sneaking up.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 21635
        • 81 Posts
        Quote from: Mark at Jul 13, 2011, 05:55 PM

        So you’re trying to hide elements from anonymous users in the front-end?

        Are you calling the chunk uncached? If you don’t it will be cached the way it is viewed the first time.

        Yes, that’s what i intended...

        and yes, calling it uncached solved the problem, thanks a lot!

        Still, in my opinion caching should be totally unrelated to access policies...
        • You could use something like the Personalize snippet which checks if a user is part of a certain group and outputs a chunk when that is (/not) the case. That way you just have that snippet uncached, but can still leverage caching on your chunk.
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
            • 21635
            • 81 Posts
            ok, but so the behaviour i got is _wanted_ behaviour?
            so that when i want to work it how it would be logical i have to run my own snippet?

            hm.. huh
            • Caching has nothing to do with user sessions - it’s very granular (it caches part of resources, individual elements etc) but caching based on a user session as well destroys the point of caching.

              The thing is - when someone visits a page that hasn’t been visited before, MODX decided (based on the cached/uncached tags you are using and other settings) that it caches parts of the resource to a file. That way when the next user checks out that page, you can quickly serve most content from file already saving a lot of query time to the database.

              Now if it would take in to account user sessions, and write cached to file with an addition session identifier you will run into two problems:
              1: you can only serve resources from cache which the user has already visited that session (which may very well be cached by the browser as well already), implying that most users will not see a file from cache at all.
              2: your cache will be enormous. If 10 visitors visit 5 pages each, that would mean you have 50 unique resource caches as it takes into account the user session. Now, if you would just cache what can be cached with the cache system as it is, you’ll only have 5 (assuming the visitors visited the same pages) cache files. So that’s only 10% of the size in your cache and with the right elements uncached no difference for the user (but probably faster pageviews as more is served from cache).


              So yes: it is wanted behavior. But easy to fix by calling the chunk uncached as it will then check for permissions every request, or using the personalize snippet which does that too.

              BTW, you can install Personalize via the package manager and more info is here: http://modx.com/extras/package/personalize

              And nothings’ wrong with running snippets - they rock and make you able to do dynamic stuff while separating content from logic. wink
                Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                • 21635
                • 81 Posts
                wow, thanks for that enormous clarification! smiley
                i really appreciate your commitment to modx, followed you along smiley

                yes, you were right, i haven’t thought of that topic as a whole. i just had my users view-point.
                totally makes sense now.

                but i guess, you can also imagine how frustrating it can be when sth behaves not as expected...

                i will definitely check out the personalize extra, and no, of course i am not against the use of a snippet smiley

                thanks again,
                cheers, niklas
                • Like I said, I had this issue myself which probably was occurring for at least a month but maybe even three months without me noticing it tongue

                  Didn’t notice it, and as it was not intentional to protect anything front-end I didn’t test it out like you are doing ^_^
                    Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                    Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.