Cache all the urls of the live site from sitemap after application build to increase performance

Namita Patil asked on January 5, 2021 19:50

Hi,

I am working on a functionality to write a script to call all the urls of Live site from sitemap xml file on application start event, so users don't have to wait for the initial load for first time for any pages. We have almost 200+ urls in sitemap file. Also, we have already enabled page level caching, so there is no issue in terms of caching. So, once all the urls are visited for first time, all these requests are getting cached and we will be good there. But, I was just curious if there is any other better way to achieve this functionality with Kentico's API (Version: 12), where all the urls will be called and cached for first time after application is built and deployed on the server. Can you please let me know if there is any better way to achieve this? Thanks!

Regards, Namita

Recent Answers


David te Kloese answered on January 8, 2021 10:45

Hi,

Are you building your site in Portal Engine or in MVC?

Is caching part the issue or the compiling part?

For the latter have you looked into precompile? https://devnet.kentico.com/articles/get-near-zero-load-time-in-both-development-and-production

If it's the actual caching part, and for some reason can't be optimized because it's just very complex or involves combining lot of data you can look into making sure the cache is build up and optimized in one go or separate task. So say you have a complex data calculation that combines a lot of tables you could create 1 task that gets all data in 1 go and stores the individual items using the same cache keys as you'll be using on the individual pages.

Have a look at the documentation for cache dependencies and using custom keys:

0 votesVote for this answer Mark as a Correct answer

Namita Patil answered on January 8, 2021 18:45

Our site is built in MVC and there is no issue for caching part or the compiling part. Caching functionality works perfectly fine. We just noticed that after deploying the code on server, it takes little more time just on first page load for each url, but all subsequent requests becomes fast as first request is being cached. So, we were trying to create a script which calls all the page urls from sitemap immediately after deployment on the server is done. All our major pages are static pages with static content like images and texts, so there is not much calculations involved here. Do you think there is some way where we can make this each first page load faster or inbuilt functionality which calls them once after deploying it on server?

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on January 11, 2021 08:35

Nothing out of the box. The only non-custom thing I can think of is using a Page Crawler search index. Just fire of the rebuild and it will index the pages live content. But as you can see in the docs this is not recommended for MVC sites as the content in the tree may not represent the actual full content.

docs.xperience.io/.../defining-local-page-indexes.

Might be easier to just setup something custom.

I'm a bit surprised that every page has this issue, and from what you describe it sounds quite straightforward content. How slow are they? How is it hosted? Have you been able to pinpoint the bottleneck? DB, images, scripts, code itself?

0 votesVote for this answer Mark as a Correct answer

Namita Patil answered on January 12, 2021 17:59

Page load is not very very slow and it is hosted on load balancer to redirect extra traffic. So far just initial load is taking bit time and we are just trying to make it better so it won't be issue after launch. For images and scripts we are using IIS compression, so no issues there. We just wanted to see if there is any existing tool/functionality in Kentico which can be used for loading all the urls in one go, then subsequent calls will be easier to load. Now, may be best way is to continue with custom setup we are implementing, where we are running batch file to request all the urls from sitemap.xml file. Thanks a lot for your help!

0 votesVote for this answer Mark as a Correct answer

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