+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Blocker Caching issue when using localisation - DomainName persistenceMode

Blocker Caching issue when using localisation - DomainName persistenceMode

8 posts, 0 answered
  1. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    03 Dec 2009
    Link to this post
    Hi,

    We are just about to switch on a large new site that uses localisation using the DomainName persistenceMode.

    See this earlier post here - http://www.sitefinity.com/support/forums/sitefinity-3-x/bugs-issues/localization-with-domainextension-does-not-work-propely.aspx

    We haven't been using page caching in DEV and UAT but we have just switched it on to prep for Production and discovered that the page gets cached the first time you visit it and exactly the same page will be served no matter what domain you are on. eg. If you got to the AU site then the NZ site you will see the AU cached page on the NZ site

    Would there be any reason for this?

    This is a pretty big issue as you can imagine how resource hungry a big site will get if there is no caching. We are using 3.7 SP1 - maybe we have some setting wrong?

    Also supposedly you can set the page caching defaults site wide in 3.7 but I haven't seen any mention of how?

    Here is our web.config settings (we will be using some cache subsitution controls):

    <caching defaultProvider="ASPNET"
            <providers> 
              <add name="memoryCache" type="Telerik.Caching.MemoryCachingProvider, Telerik.Framework" /> 
              <add name="ASPNET" type="Telerik.Caching.AspNetCachingProvider, Telerik.Framework" duration="120" slidingExpiration="true" /> 
            </providers> 
            <cacheDependency mode="InMemory" enablePublishingService="true" /> 
    </caching> 


    Thanks

    Seth
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    07 Dec 2009
    Link to this post
    Hi Seth Cleaver,

    You are right. I will explain you why this happens. 

    The objects are being cached and referenced by keys. What happens in this case is that the key for both objects (both language versions) is the same. This can be changed very easy though. 

    Open your global.asax file, and find the following row:

    public override string GetVaryByCustomString(HttpContext context, string custom)
     
    {
    if (custom.Equals("cms"))
    {
     
    return String.Concat(context.Request.RawUrl, context.Request.Browser.Type).ToLower();
     
    }
    return base.GetVaryByCustomString(context, custom);
    }

    By default, the key for the different pages is the RawUrl. It turns out that for your case, the RawUrl is the same for both versions. We are also taking into account the browser type, since the rendered html could be different depending on the browser capabilities (Asp.net feature). You can add another key:

    public override string GetVaryByCustomString(HttpContext context, string custom)
    {
    if (custom.Equals("cms"))
    {
     return String.Concat(context.Request.Url.Host, context.Request.RawUrl,  context.Request.Browser.Type).ToLower();
    }
     
    return base.GetVaryByCustomString(context, custom);
     
    }

    This way you will have the host name to the key so the domain name will be taken into account.

    Hope this helps. 

    Sincerely yours,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    07 Dec 2009
    Link to this post
    Hi Georgi,

    Thanks very much that seems to have fixed it.

    Do you know though I thought I saw a comment somewhere that 3.7 had a setting that allowed you to set the page cache default right across the site to true rather than false.

    Was I dreaming?

    Seth
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    07 Dec 2009
    Link to this post
    Hi Seth Cleaver,

    You wasn't dreaming ;) 

    I believe the following forum thread will provide you with the answer you are looking for - http://www.sitefinity.com/support/forums/sitefinity-3-x/developing-with-sitefinity/defaulting-enable-cache-to-true-and-cache-expiration-value.aspx

    Best wishes,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    11 Dec 2009
    Link to this post
    Hi Georgi,

    Thanks so much for all the assistance there. We could activate page caching in the end because we have one thing on the page using CacheSubsitutionUserControl and discovered that HttpContext.Current.Profile isn't available in Cache Sub Controls. So we had to turn it off... which is a bummer. We will have to look at it again when  we have time to find a work around.

    Anyway we were setup our app ready for deployment and came across one more caching mystery today. In images and documents module we were setting the expire setting on each library and also ticked "enable caching" for images in that library. Expires seems to work but when we tick enable caching the images from the library disappear from the site. Untick it and they appear again.

    Does this setting not work? We are using IIS7. We updated to 3.7 SP2 but this did not resolve the issue.

    Thanks

    Seth
  6. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    11 Dec 2009
    Link to this post
    Hi Seth Cleaver,

    This happens because you use ASPNET as a caching provider. ASPNET doesn't have implementation for caching items in Images and Documents module - it's the native caching mechanism provided by the .NET framework (with some little extensions). In order to use the server side cache of these items, you have to switch to memoryCache, or use the Client Side caching - Client Side settings are located in the More Option section as well - "How long should the browser cache an image or a document?"

    The second option is producing good results for visitors that come back to the site - they will already have local copies of the images in their temp directory, and no server work will be required.

    Let me know if you have any further questions. 

    Greetings,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    11 Dec 2009
    Link to this post
    Hi,

    Well that makes sense now. I couldn't find this explanation anywhere.

    Guess we will stick with client side caching as we will need to use the Cache Sub User Controls in the near future so ASPNET provider is the best one.

    Thanks for the reply.

    Seth
  8. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    11 Dec 2009
    Link to this post
    Hi Seth Cleaver,

    I agree on the documentation part. 

    We are taking different concept for 4.0 though - once we introduce a feature, we document it. I am sure that this will bring us good results. 

    Needless to say, let us know if you have need any assistance when you begin your implementation in the future. 


    Best wishes,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
8 posts, 0 answered