Ali Khakpouri
Ali Khakpouri

Reputation: 873

Sitecore cacheable & Cassette

Inside of my rendering's markup, I'm adding a reference to a series of .less files using the Bundles.Reference. When I enable caching on this component, the less files won't get added to the <head>.

@model Sitecore.Mvc.Presentation.RenderingModel
@{
    Bundles.Reference("~/resources/less/interior", "header");
}

Upvotes: 1

Views: 77

Answers (2)

Ali Khakpouri
Ali Khakpouri

Reputation: 873

Move your Cassette's Renderings into a viewer rendering.

@Bundles.RenderStylesheets("global")
@Bundles.RenderStylesheets("header")
@Bundles.RenderScripts("global")
@Bundles.RenderScripts("header")

Add this rendering to sitecore. As seen in this screenshot.

Add your rendering to your layout. This will cache it by the page hits.

@Html.Sitecore().Rendering("<your rendering definition item id>", new { Cacheable = true, CacheKey = "my_rendering", Cache_VaryByData = true })

Upvotes: 1

Gatogordo
Gatogordo

Reputation: 2635

You can't have both cache (output cache) and expect your code to be executed. So either you cache, but then you need to put that code somewhere else. Or you don't (output) cache. But (output) cache and executing the code are mutually exclusive.

Upvotes: 0

Related Questions