I received the following question on the functionality of CF_Accelerate and wanted to share how I worked around it.
"Got a questions regarding the CF_Accelerate customtag you have created. The caching is set according to the querystring and filename right? Well when you have an application that requires users to login, a session will be set whether or not the user is logged in. Now here comes the problem. It doesn't matter whether you are logged in or not, the same pages and its querystrings will be used. So when you log in and the page is cached when you're logged out, the logged in user will still see the page as if the user was logged out. Because the check is being done by sessions. Do you recognize this problem and do you have a solution to this, or areyou working on something to overcome this? "
This question caused me problems on my own site. But there is an easy work around. CF_Accelerate without any arguments will exhibit this behavior. The cached is built in a tree based on three attributes:
- attributes.scriptName - first key defaults to the cgi.script_name
- attributes.primaryKey - second key defaults to the query string
- attributes.secondaryKey - third key defaults to the string "default"
The third key is not really used but it is there if you need it. In your case you could use use a session variable as the secondaryKey to determine if the user is logged in and it will cache different data if they are logged in. For example
session.loggedin could be true/false or whatever you want.
On my site when I am logged in I don't cache the data. So I used something like
If a user is logged in the data is not cached at all. If a user comes to the site session.IsLoggedIn is false and the data comes from the cache. There may be a better solution, feel free to share your thoughts.
This is indeed a very easy solution. When you define usergroups, which have access to a specific piece of content, you can even use #session.loggedOn##userGroups#
userGroups variable can be passed like a List then.