Cache automatically

Kenny Deblaere asked on January 19, 2017 15:23

Hello

I'm using Kentico 9.50, and declared my output caching. The output caching time is 30 minutes and it's working fine.

After 30 minutes the problem is: the first time a page is visited, the loading time feels very long, because the loading time with caching is 800ms and without it's 4s.

Is there a way to 'preheat' Kentico, so the page is automatically cached again?

Kind regards

Kenny

Correct Answer

Trevor Fayas answered on January 19, 2017 16:19

First, as the others mentioned, make sure there's not a deligitimate reason for the slowness (bad query optimization, not setting the "Columns" to return only necessary data, not caching right, etc).

To answer the question on how to 'preheat' a site, one of two ways we have used with systems that were slow because of external resources not being provided fast enough.

  1. use the smart search index "Web crawler" set on a scheduled task to crawl the pages, although usually you set something like a full day cache and run this once.
  2. If it's a small set of pages you want high priority heat on, setting up a pinging service on these pages can have them continually 'hit' and thus rendered and cached.
0 votesVote for this answer Unmark Correct answer

Recent Answers


Peter Mogilnitski answered on January 19, 2017 15:56 (last edited on January 19, 2017 16:03)

You set caching based on the nature of your content. Are you saying your page completely changes after 30 mins? This is highly unlikely. I normally set output cache for 24 hours+. Secondly you can use substitution macro. For example your page is pretty much static except the news. You can do your news via substitution macros.

P.S. it takes 4 seconds? - you have to look at the SQL queries: settings > systems > debug Make sure that "disable debugging" is unchecked at the top and check: "Enable SQL query debug" and "Display SQL query debug on live site". Now you page will display all SQL queries at the bottom. See what queries you have on you page and why it is taking that long.

0 votesVote for this answer Mark as a Correct answer

Kenny Deblaere answered on January 19, 2017 16:03

Hello Peter

My pages do not change much, only sometimes a week, the substitution macro seems interesting, but what happens when the app restarts?

Kind regards

Kenny

0 votesVote for this answer Mark as a Correct answer

Zach Perry answered on January 19, 2017 16:04

Have you looked into what is causing the slow loading time?

Some of these articles might help:

Brenden's Post

Roman's Post

Martin's Post

Those might help you get to the root of the slowness, if that doesn't help you could also increase your cache time, or set up something that would constantly load the site to keep the cache fresh. I think you can set something up like this with azure insights.

0 votesVote for this answer Mark as a Correct answer

Kenny Deblaere answered on January 19, 2017 16:22

Hello Zachary

I've followed a lot of articles to speed up the website. I've been doing some logging on my own, to find the most load time.

Now with the caching, the website runs good.

0 votesVote for this answer Mark as a Correct answer

Kenny Deblaere answered on January 19, 2017 16:24

Hello Trevor

Can you give me some more documentation about the web crawler? Does this also work for caching the sites running on a domain?

Kind regards

Kenny

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on January 19, 2017 18:04

Sure, the Web Crawler is just another type of "Smart Search" index you can run. Unlike the normal Pages index, it actually loads the page so it can put all the rendered content in it's cache (normal Pages index only indexes content on the page, but not rendered items like repeaters and such).

Because it renders the page, any caching will take place.

https://docs.kentico.com/k10/configuring-kentico/setting-up-search-on-your-website/creating-search-indexes

If you ever use the Crawler for your actual Search of your site, see my blog article on how to exclude header/footer from the indexed content.

0 votesVote for this answer Mark as a Correct answer

Kenny Deblaere answered on January 19, 2017 19:21

Hi Trevor

I'm trying your solution, but I guess it's necessary to do this for all your domain aliases, just for one after each other.

I'm guess, when looking into your blog posts, it's possible to render all the pages for all domain aliases?

Kind regards

Kenny

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on January 19, 2017 19:27

Possibly, but a domain alias shouldn't change the content, and i don't think it would affect the cache (the same page's cache should hit for both domain aliases i believe), so scanning one of the domains should cache for all the aliases. If not though you can create multiple Smart Search Indexes, one for each domain.

0 votesVote for this answer Mark as a Correct answer

Kenny Deblaere answered on January 19, 2017 19:31

Yes I know, they share the same content, but there are a few little differences (another image/other logo), witch made me configure the Output Caching different for each domain.

I guess the best thing is to give it a go.

If it works, is it possible to run the crawler everytime the application starts?

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on January 19, 2017 20:00

Yeah, if you look at adding a Custom Loading Module, the OnInit runs once per application start, you can add the call to run the smart searches there, just be careful with running multiple searches on the same pages, they tend to freeze up, best to run one after another.

https://docs.kentico.com/k10/custom-development/handling-global-events

0 votesVote for this answer Mark as a Correct answer

Kenny Deblaere answered on January 19, 2017 20:16

Great thanks, I will check to let one index run and handle all my domains at once, if possible. This one, I'm going to run every night and/or when the application starts.

Thank you for your help Trevor.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.