I have Content delivery API which works fine. I also use CustomContentModelMapper to modify/update response.
I have a page that has ContentArea property that has multiple article pages (around 20) and this page is frequently hit with ExpandCollection being true. We have observed latency when there are large number of hits on this page.
Is there a way I can cache data for this page only for API route or any suggestions on improving the process.
Without knowing much about your solution architecture the quick & easy solution is to use the Azure API Gateway. It provides a cache solution & other really cool functionality. See this blog
I have the mapper to return custom mapping of referenced pages. Example, the current page references few profile pages so instead of sending the content ids by default (as with default implementation) I am fetching the content using contentloader service and mapping them into an object before sending the data back. This is the only custom thing am doing with API. Other than that everything is pretty standard.
Going by some articles, I see that I could add cache conttrol header and also have EpiServer support enable page level rules for CDN caching. I don't know at what level that data is cached, I mean I don't want all users seeing same data if there are any personalizations. Not sure what the best approach here would be.
Matthew Moles blog describes CDN cache for Content delivery API - That's a good approach but I probably avoid it.
The whole point of using CDN cache is it stored static data in the local data centre. So if I access the website from the UK, it serves me static content from the UK data centre. This static content does not change very often. For example image or Js/CSS files etc.
Now for services, the cache should be implemented to an object-level (unless you are developing a brochure website). You probably need different content for a different set of customers Also you do not want to expose your parameter to retrieve your content.
I believe Episerver intentionally did not implement CDN cache on Content delivery API. Content delivery API uses IContentLoader which is cached anyways.
Sorry, it's not a direct answer to your question but every project is different and you need to make a decision based on your requirements.
No worries Naveed and thank you for taking time on providing details. All the information provided here is helpful in someway for sure. I certainly don't want to rush for any solutioning without properly understanding pros and cons.
I have gone through the article mentioned already and am certianly not sure of doing a CDN cache as my response could be personalized based on audience. I will possibly dig deep to understand what the issue actually is and why is my API choking while site continues to work just fine.
I am reaching out to forum to see if there are any obvious things that I may be ignoring or if there is something I should avoid in the mapper itself.