Free Support Forum - aspose.com

Caching a PPTX?

Hi all,

What’s a good way to cache a PPTX file?

@hanyancode

Can you please shared the details of your requirements regarding Caching PPTX?

Right now my (.NET) code looks like this, and whenever I try to retrieve it from the Cache, I’m missing PPTX slides:

Presentation pres;
System.Web.Caching.Cache Cache = new System.Web.Caching.Cache();

if (Cache["myKey"] != null) pres = (Presentation)Cache["myKey"];

else {
        PPTMemoryStream = new MemoryStream(client.DownloadData(url));
        PPTMemoryStream.Position = 0;
        pres = new Presentation(PPTMemoryStream);
        Cache.Add(
            key: "myKey",
            value: pres,
            absoluteExpiration: DateTime.Now.AddHours(2),
            dependencies: null,
            onRemoveCallback: null,
            slidingExpiration: System.Web.Caching.Cache.NoSlidingExpiration,
            priority: System.Web.Caching.CacheItemPriority.Default
        );
    }

@hanyancode

I have created an issue with ID SLIDESNET-42128 as investigation to further analyze the requirements. At present, Aspose.Slides does offer the support for saving as memory stream and you can save memory stream to byte array or blob if required.

Update: I was able to prevent data loss in the cache by caching the MemoryStream (PPTMemoryStream) instead of the Presentation object (pres). However it still takes 2-4s to get the file from the cache… about the same amount of time it takes to originally download the file.

@hanyancode

I have added the information in our issue tracking system and will share the feedback with you as soon as the issue will be addressed.