1
I'd like to know how to use cache correctly.
Question asked by ssemi - 7/9/2024 at 3:28 AM
Answered
Hello,

The situation is like this.
Use azure blob storage. Since it is a private container, file control is performed using SAS tokens.

When preCacheing an address with a SAS token, I want to put document(FileProvider) in, but I don't know how to do it.

I am only looking for the information given.

Currently, it is called as below, but if you do this, the SAS Token changes every time, so it is not cached.

DocumentViewer.Document = FileProvider.Parse(urlWithSASToken);

And, I can't handle DocumentCacheInfo object to change to FileProvider.

var documentcacheInfo = new DocumentCache(azureBlobLocation).LoadCacheInfo(fileCache.Key);
I would like to know exact examples of cache and how to use it.
It's difficult to find because there are no hints or documents anywhere in the manual.

Finally,
// preCacheDocument
var fileProvider = FileProvider.Parse(urlWithSASToken);
var documentCache = new DocumentCache(_azureBlobLocation).PreCacheDocument(fileProvider);

// use DocumentViewer 
var documentViewer = new DocumentViewer(webConfiguration);
documentViewer.InitializeOption(someOptions);
// I don't want to use this, I just want to use pre-cached information.
documentViewer.Document = FileProvider.Parse(urlWithSASToken); 
// like this           
documentViewer.Document = PreCachedInfo ?? FileProvider.Parse(urlWithSASToken); 

Thank you.

1 Reply

Reply to Thread
0
Cem Alacayir Replied
Employee Post Marked As Answer
When you PreCacheDocument, later then you set documentViewer.Document to the same File/FileProvider so that DocumentCache knows it's the same file and matches the cached item.

CacheSourceKey is generated according to combination of file extension, file modified date and file size info.

You say your urlWithSASToken changes but are you sure "file extension, file modified date and file size info" changes. For a UrlFileProvider, a HTTP request may be sent everytime to get this info but if the info is same the conversion will not occur, already cached item will be used.

Reply to Thread