Pages

30 September, 2016

Sitecore MVC – Custom Vary by cache options

Sitecore, by default, provides varies options like Vary by Data, Vary by Query String to enable HTML cache. Sometimes we need other options (based on component built type) to help the component cached by Sitecore cache.

I have created a custom module helps in adding options to cache based on URL and Rendering Unique ID.

After installation, you will see two options in caching section of rendering definition.
  • Vary by URL
    • Cache key varies by HttpContext AbsolutePath
    • Can be combined with other options like query string (existing)
  • Vary by Unique ID
    • Uses rendering unique ID
Also, page presentation component properties will have the same option and there will be an additional option to disable the rendering definition cache settings – Cancel Cache Settings. (ref link). 

Now you enable cache based on incoming URL and rendering Unique ID. Also disable the rendering cache setting in Page presentation component properties. 

No comments:

Post a Comment

blockquote { margin: 0; } blockquote p { padding: 15px; background: #eee; border-radius: 5px; } blockquote p::before { content: '\201C'; } blockquote p::after { content: '\201D'; }