Last active
August 7, 2018 03:46
-
-
Save weirdpattern/053e37fcb2137d82b7a8821ef972c73e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Sets the cacheability of a rendering. | |
/// </summary> | |
public class SetCacheability : Sitecore.Mvc.Pipelines.Response.RenderRendering.SetCacheability | |
{ | |
/// <inheritdoc /> | |
protected override bool IsCacheable(Rendering rendering, RenderRenderingArgs args) | |
{ | |
Assert.ArgumentNotNull(rendering, nameof(rendering)); | |
var disableCaching = rendering.Parameters[Templates.Pipelines.SetCacheability.DisableCaching]; | |
if (!string.IsNullorWhiteSpace(disableCaching) && disableCaching == "1") | |
{ | |
return false; | |
} | |
return base.IsCacheable(rendering, args); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"> | |
<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="MyCustom.Assembly.Pipelines.RenderRendering.SetCacheability, MyCustom.Assembly" /> | |
</mvc.renderRendering> | |
</pipelines> | |
</sitecore> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment