Extranet caching trouble

Topics: General, Troubleshooting
Jul 22, 2011 at 8:51 PM

We're having some issues with extranet "caching" the login status of the current user. 

We have buttons in the navigation for login/register that change to logout/my account.  When jumping around from page to page after logging in, they sometimes switch back to the logged out state, but then going to the next page will make them be the correct logged in state. 

I've tried commenting out the <%@ OutputCache Duration="60" VaryByParam="*" VaryByCustom="C1Page" %> line in Page.aspx, which was suggested in a similar post I made.  That doesn't seem to help very much.

One thing I have noticed, is that if I add an extra parameter to the URL, like a &time=123456 (or using system ticks or something random), the state of the pages is then correct.  It's almost like the pages need a full refresh when on the page to make sure they are happy. 

Are there any tweaks/settings for something like this, or does this ring a bell for anyone?  I hate to ugly up my pretty URL's with these extra parameters in them, but that seems to be the only way to get a real fresh page to be displayed.

As always, thanks for any suggestions you can throw out there.

~Brian

Coordinator
Jul 25, 2011 at 7:44 AM

Hello,

It is known cache issue with Extranet Login/Logout status and generally the solution is to disable page caching in file ~\Renderers\Page.aspx and  it is strange that it doesn't help.

Could you try another solution. On the function where you have navigations for login/register disable cache by adding following code:

System.Web.HttpContext.Current.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);

 

If your links in XSLT, then you can add this code something like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	exclude-result-prefixes="xsl in lang csharp"
	xmlns:in="http://www.composite.net/ns/transformation/input/1.0"
	xmlns:lang="http://www.composite.net/ns/localization/1.0"
	xmlns:f="http://www.composite.net/ns/function/1.0"
	xmlns:csharp="http://c1.composite.net/csharp"
	xmlns="http://www.w3.org/1999/xhtml">

	
	<xsl:template match="/">
		<html>
			<head>
			</head>
			<body>

					<xsl:value-of select="csharp:SetNoCache()" />
					<div class="LoginStatus">
                             ....
					</div>
			</body>
		</html>
	</xsl:template>

	<msxsl:script implements-prefix="csharp" language="C#" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
		<msxsl:assembly name="System.Web"/>
		<![CDATA[
     public void SetNoCache()
    {
      System.Web.HttpContext.Current.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
    }
  ]]>
	</msxsl:script>

</xsl:stylesheet>

 

Jul 25, 2011 at 9:52 PM

Adding the code in the page seems to have fixed it up pretty good.  We'll do more extensive testing, but right now, it's looking pretty good.  Thanks a bunch.