November Happy Hour will be moved to Thursday December 5th.

Caching GetVaryByCustomString for CMS 12

Vote:
 

Hello,

We are referring solution given in this link for implementing VaryByCustom caching. But it is not going through this method.

Can anyone suggest on what might be missing for this to work or help on how can this implemented in CMS 12 to work.

Thanks,

Deepa

#302324
May 25, 2023 5:04
Vote:
 

Hi Deepa,

I had a look through the blog post and I just wanted to check you have done the following:

  1. Installed the nuget package.
  2. Configured it as per the readme .
  3. Add the Attribute to a controller and tested '[ContentOutputCache(Duration = 86400)]'.

If this is all working then I think a good place to start looking is the order of the service registration.

From the first blog you should have added:

services.AddOutputCaching();

To then use the custom implementation of 'IOutputCacheVaryByCustomService' you would need to call the service registration after this:

services.AddTransient<IOutputCacheVaryByCustomService, OuputCacheVaryByCustomService>();

Does this all look like your code?

You can see the example startup.cs here

Paul

#302327
Edited, May 25, 2023 8:41
Vote:
 

Yes followed all these steps as mentioned here. 

#302328
May 25, 2023 9:13
Vote:
 

I believe no content cache will work unless you set the content cache properties in appsettings, see https://docs.developers.optimizely.com/content-management-system/docs/configuring-cms#contentoptions

E.g.

  "EPiServer": {
    "CMS": {
      "Content": {
        "VersionCacheSlidingExpiration": "0:0:10",
        "ContentCacheSlidingExpiration": "0:0:10"
      }
    }
  }
#302329
May 25, 2023 10:59
Vote:
 

Hello,

Yes added this configuration in appsettings.json file. It will not fire the GetVaryByCustomString() method from service.

Do we need to call this method explicitly apart from adding this line [ContentOutputCache(Duration = 86400, VaryByCustom="visitorgroups")] for controller action method?

Thanks,

Deepa

#302645
May 30, 2023 9:09
Paul McGann (Netcel) - May 31, 2023 9:55
Hi Deepa,

I have created a simple demo site with this working.

You can find this here https://github.com/paulmcgann/optimizlely-content-output-cache-visitorgroups

Just to note, on the first load f the site the startpage will not hit the implementation, however if you browse the site then go back to the startpage it will hit it.

Paul
Deepa Puranik - May 31, 2023 16:00
Hello Paul,

Thank you so much for all help.
I did configure it the way it is there in this repo. Thank you again.
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.