Performance Issue with Page Count Retrieval on First Request

We are experiencing a performance issue with the Aspose library when retrieving the page count for the first time after the application starts. The first request takes significantly longer compared to subsequent requests, which are much faster.

We would like to know:

Is there a way to retrieve the page count without loading all document formats?

Are there any alternative approaches or optimizations for getting the page count efficiently?
Code Snippet Used:

using (Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(inputPath))

{

PageCount = pdfDocument.Pages.Count;

}

Please provide guidance or suggestions to optimize the page count retrieval process, especially for the first request.

@subramanyam.gvsrb
If that issue is universal or there’s specific files that has such slow performance on first count?