test for user logged in server cache issue #254
Replies: 6 comments 2 replies
-
|
It's likely a cache key issue. You need to set a different cache key for any unique razor file rendering. If your display targets a specific role then you would want to ensure your cache key includes a role id or role name to differentiate it from the unauthenticated users or users in different roles. You'll just have to modify your custom theme templates so the params being used in the calls to the render functions reflect above. |
Beta Was this translation helpful? Give feedback.
-
|
There may be other approaches that @leedavi can share but one can solve this with a pre-processor meta token. We added a pre-processor meta token to ProductDisplayAjax page and changed the moduleId param by appending a value(userid or roleid). I don't think it involved other code changes but I tackled this a while ago so you'll need to test. https://github.com/nbrightproject/NBrightTS/blob/c05d6d4a4a1fe31d6e70d0dbf3e7603b6db42a49/render/RazorEngineTokens.cs#L62 |
Beta Was this translation helpful? Give feedback.
-
|
I'm running into something similar and running in debug mode seems to help. I will try the pre-process token |
Beta Was this translation helpful? Give feedback.
-
|
Can anyone advise how to add the pre-process function in a template as I am not sure how to do this? |
Beta Was this translation helpful? Give feedback.
-
|
I'm unsure the pre-process will work. It's usually is for SQL selections, so the selection itself can avoid caching. The problem is that the user is not recognized as a cache trigger, for obvious reasons that in theory users can be unlimited, so caching on them would not help high load websites. I don't like running in debug mode, but it is a way to deal with it. If the website doesn't have a large amount of traffic, it is a workable solution. So, I think you have 2 options that can work.
Option 1 should be OK with a low volume website. If you find it slow then option 2 is the option. |
Beta Was this translation helpful? Give feedback.
-
|
Ideally, it would be nice to have a Pre-Process token that specified any additional cache values or turned on/off cache for that template. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using the following to check if a user has a specific role and if a product has attached documents to display the downloads.
@if (DotNetNuke.Security.PortalSecurity.IsInRole ("abc") == true) {
if (@product.Docs.Count >= 1)
The issue I am having is that when a user logs in or out I have to clear the server cache before the razor view updates. Can you advise if there is a way to resolve this or a better way to achieve what I want?
Thanks
Roger
Beta Was this translation helpful? Give feedback.
All reactions