Caching enabled for all the pages in single place

Posted by Community Admin on 03-Aug-2018 09:16

Caching enabled for all the pages in single place

All Replies

Posted by Community Admin on 25-Jan-2011 00:00

I know that to set the caching for a page I need to go to page -> Title & Properties -> Advanced Options -> Enable Caching

But I have to enable caching to almost 100 pages. I have to enable caching for all 100 pages then I will have to visit 100 pages and set caching option. Instead is there a mechanism by which I can set caching options enabled for all the pages in single place.

Any suggestions?

Posted by Community Admin on 25-Jan-2011 00:00

Hello praveen,

The PageData has a property CacheOutput which you can set to true programmatically for all pages. You can use Pages facade

sample

using(var fluent = App.WorkWith())
      
          fluent.Pages().ForEach(p => p.Page.CacheOutput = true);
      


All the best,
Ivan Dimitrov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 27-Jan-2011 00:00

 I tried your code by placing it at “Application_Start” event but it used to give me “Object reference not found error” then I moved it to one of my page again I used to get “Object reference not found error”.

So I had used following code:

var pages = App.WorkWith().Pages()
                    .LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
                    .Where(page => page.ApprovalWorkflowState == "Published")
                     .Get();
                    foreach (var page in pages)
                    
                        page.Page.CacheOutput = true;
                    

 

To execute this code I need the user to have some permissions and I cannot assign permissions to all the users visiting my site. So how do I enable global caching.

Please suggest.

 

Posted by Community Admin on 28-Jan-2011 00:00

Hi praveen,

You are getting a null reference, because some object from your expression returns null. Also p.Page is a PageData and if you have a group pages you will get this exception. Also you can execute the code from a user control instead of Application_Start which is called inside Global.asax

Best wishes,
Ivan Dimitrov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed