2

I am trying to upgrade the old project(based on storefront for Sitecore 8.0) to version Sitecore 8.1(latest one at the moment). During this process I faced with a problem when I see the same products for all categories. So, for example, I select a category first time and see correct products. After that I choose any other category, but still see the same products(from the first category). These data are returned by ProductList rendering(a controller rendering) and it is not run after the first call anymore(tried to reach corresponding action in a CatalogController in debug mode). If we clear all caches(..sitecore/admin/cache.aspx) - then it works again, but only first time.

I understand that I can't disable caching for the whole site, I need to do it for this generic page(with "*" in item name) where the commerce data are shown - so for all categories and product pages. I checked this rendering in design mode and can see that all checkboxes related to cache are unchecked at the moment. Don't know what I have missed.

Thank you in advance for the help.

Max
  • 804
  • 7
  • 19
  • 2
    Have you checked caching settings both on the control level (in presentation details of your page item) and on the layout definition item (under /sitecore/layouts)? My bet is that you only checked in one of these places, and the other has caching checkboxes checked. – Dmytro Shevchenko Aug 02 '16 at 14:49
  • Yep, your suggestion was a correct one. Initially I checked the caching settings in rendering(which is added to some item layout), but have not checked the settings of the rendering itself. Please add you suggestion as an answer, I think it might be useful for so forgetful persons like me. Thank you! – Max Aug 02 '16 at 15:21
  • 1
    By the way, I found that this rendering also has a caching setting related to Url paths(http://screencast.com/t/1kbwHv3KulzN), but it didn't help in this situation. I think it should work(because each category has a different URL), but it doesn't. – Max Aug 02 '16 at 16:07

2 Answers2

4

I believe you have caching enabled on control/sublayout defintion level which will cause to cache that rendering on every page on the site, a while ago i was able to come up with a solution to disable caching for a specific rendering/sublayout on specific pages, while keeping it caching on other pages.

I basically created a new rendering parameter template with checkbox "Cancel Cache Settings", then in my rendering definition item, I set the parameter template to the new template, if your site runs on Sitecore MVC, do the following:

Create a class called 'SetCacheability'

namespace Sitecore.SharedResources.Pipelines.Rendering
{
    public class SetCacheability : Sitecore.Mvc.Pipelines.Response.RenderRendering.SetCacheability
    {
        protected override bool IsCacheable(Sitecore.Mvc.Presentation.Rendering rendering, Sitecore.Mvc.Pipelines.Response.RenderRendering.RenderRenderingArgs args)
        {
            if (!String.IsNullOrEmpty(rendering.Parameters["Cancel Cache Settings"])
                && rendering.Parameters["Cancel Cache Settings"] == "1")
            {
                return false;
            }
            return base.IsCacheable(rendering, args);
        }
    }
}

Create the patch config file in your include folder:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <mvc.renderRendering>
        <processor patch:instead="processor[@type='Sitecore.Mvc.Pipelines.Response.RenderRendering.SetCacheability, Sitecore.Mvc']"
          type="Sitecore.SharedResources.Pipelines.Rendering.SetCacheability, [YOUR ASSEMBLY NAME]"/>
      </mvc.renderRendering>
    </pipelines>
  </sitecore>
</configuration>

Here is the blog i wrote on this: http://www.sitecorecoding.com/2014/09/disabling-caching-for-rendering-on-some.html

Hope this helps

Stijn De Vos
  • 312
  • 3
  • 8
Ahmed Okour
  • 2,392
  • 1
  • 16
  • 31
  • Hi Ahmed, thank you for the help. Dmytro has solved my problem a little bit earlier than you. – Max Aug 02 '16 at 16:10
1

The caching settings you've disabled are located in the presentation details on the control level:

Presentation-level caching

Additionally, you should ensure that caching is disabled on your sublayout (or rendering) definition (under /sitecore/Layout/Sublayouts):

Sublayout definition caching

Dmytro Shevchenko
  • 33,431
  • 6
  • 51
  • 67