7

We are trying to implement SiteEdit on a DD4T enabled website.

If we make changes to content and exit SiteEdit by selecting Cancel Editing the changes that were made are still reflected on the pages even though we did not save the changes by selecting Finish Editing. Only once we close the browser and then reopen the page are these changes gone.

Is there a way to make sure the changes are not reflected on the page after exiting SitEdit if we do Cancel Editing? We have disabled caching and still the problem persists. Is there anything we are missing out?? Any help would be appreciated...thanks in advance..!!

  • +1 for catching and asking about this behavior. It's worrisome to think you've cancelled editing but aren't quite sure if it really cancelled. – Alvin Reyes Nov 7 '13 at 12:39
6

The DD4T object cache by default checks for the last publish date of the underlying Tridion components and pages. The problem with Session Preview in Experience Manager is that it does not change the last publish date. This can cause your web application to cache the temporary content created during an XPM session, and use that even after the XPM session has been closed.

The easiest solution would be to use DD4T's NullCacheAgent instead of the DefaultCacheAgent. This can be done by setting the CacheAgent property on the PageFactory and ComponentFactory in your controller. You could for example put the following code in your page controller:

 private IPageFactory _pageFactory = null;
    public override ContentModel.Factories.IPageFactory PageFactory
    {
        get
        {
            if (_pageFactory == null)
            {
                _pageFactory = base.PageFactory;
                _pageFactory.CacheAgent = new DD4T.Factories.Caching.NullCacheAgent();
            }
            return _pageFactory;
        }
    }

Alternative solution You could also disable caching per item type, for example for components only. This can be done by putting the following line in the appSettings section of the web.config:

<add key="DD4T.CacheSettings.Component" value="0" />

This way, pages and things like sitemaps are still cached, improving the performance of your staging environment. In the live production environment you should turn on caching.

| improve this answer | |
  • We have tried by adding <add key="DD4T.CacheSettings.Component" value="0" /> to appSettings in the web.config but that did not solve the problem. – t2013 Nov 7 '13 at 12:30
  • Have you tried the other solution also? – Quirijn Nov 7 '13 at 13:58
  • The VS studio solution is not at our end, hence can't access the controller to try that out. – user734 Nov 7 '13 at 14:53
  • Wouldn't changing the code to use a null cache agent going to impact production as well as staging? Is there any way to set the cache agent via dependency injection? – Rob Stevenson-Leggett Nov 9 '13 at 15:09
  • Yes, if you have DI you can simply set the CacheAgent property of your factories. – Quirijn Nov 11 '13 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.