1

I want to enable caching on Spotlight Widget Rendering, which is added on multiple pages. And we want to enable it for 2 sites only.

Can anyone please help me in this?

1
  • Are you using SXA? Is the "Spotlight Widget" something built custom by your team? May 8, 2023 at 18:50

6 Answers 6

1

If you are not on SXA, then you can set follow the below steps:

  1. Go to the particular page.
  2. Go to the presentation->Details.
  3. And go to the particular component where you want to apply to the cache.
  4. And in the Caching section, you can apply caching. enter image description here

And for SXA you can check here

1

Hey @Rohan G I would suggest you add your rendering to template _standard value and apply caching there. It will help you in appearing rendering on multiple pages/items of the same and different templates, regarding your second point

we want to enable it for 2 sites only.

I'm not aware about your content tree structure but if you've some site-specific templates you could probably remove that rendering from the final layout, another option could be to use the personalization rule which will return true/false based on allowed/disallowed sites

0

You can apply cache at the item level, you just need to go to the item presentation details.

Content Editor > Page Item > Presentation Details > Click on the rendering.

This option will work only for this one item and one instance. This is generally not recommended and usually, something that your content authors really should not need to know about.

enter image description here

Hope it helps!

0

There are different ways to apply caching, you can choose or customize it based on your requirement:

  • If caching to be apply at all places wherever component added on page then apply it at rendering level itself
  • If you are adding rendering on standard value of any template so that its all items have it (irrespective of site) then apply caching at template level presentation itself
  • you can create a powershell script and apply caching to all items of required sites
  • I guess personization suits for scenario where you need control over visibility of rendering or manage different datasources based on different rules
  • if required you can customize item save event and apply your caching updates there.

Let me know if none of these condition works for you

0

You can specify rendering caching options in two ways:

  • Globally – specifying the options in the definition item of the rendering. This is then the default setting for all uses of this rendering.
  • Locally – specifying the options every time you use a rendering. Note: If you change the cache settings for a component at the page level it will override the default global settings..

So I would suggest applying it globally using the Standard value option and then you can run a PowerShell script to update it for other sites where you don't need that.

This is a good article you can follow to know about Tips for Monitoring and Tuning Sitecore Cache

If you see this, you will find a PowerShell script that gives you the details of local cache settings. So you can modify this as per your needs.

Hope this helps.

0

You can use the Below Powershell Script if you want to enable the caching on Multiple Pages having Spotlight Widget Rendering

# Set the startPath as per the requirement
$startPath = "master:/sitecore/content/Home"
$items = Get-ChildItem -Path $startPath -Language "en" -Recurse
foreach ($item in $items)
{
    $renderingInstance = Get-Rendering -Item $item -FinalLayout
    foreach($renderingObj in $renderingInstance)
    {
        $renderingItem = Get-Item $renderingObj.ItemID
        #ADD the Rendering ID on which you want to enable caching
        if($renderingItem.ID -eq "{DD8E8E1F-5532-4638-9FF2-58D0E0264B08}")
        {
            $renderingObj.Cachable = 1
            $renderingObj.VaryByData = 1
            Set-Rendering -Item $item -Instance $renderingObj
            Write-Host "Caching Enabled on --" $item.Name  "||" $item.ID
        }
    }
}

Refer - https://insightswithvishalkhera.wordpress.com/2023/03/01/powershell-script-to-enable-caching-on-sitecore-rendering/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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