Free Support Forum -

Viewer with cache


Good morning,
I have doubts about using the Viewer with the cache.
I want to view files with the same name. The viewer shows me the first file displayed, because the cache already has a file with the same name. How should we behave in this case?
I tried to save the files with a guid, but obviously I lose the benefits of the cache.
If instead I save with a unique identifier, how do I manage any updates to the file?

Thanks in advance.



Thanks for posting your inquiry.

Would you please share with us how are you managing the files with the same name in the storage folder? Do you replace the existing file in the storage folder with a new file having the same name and the storage folder contains only 1 file at a time? It would be helpful for us if you share the workflow of document rendering in your case. If possible, you may also share with us a sample application that can be used to demonstrate your use case. We shall be looking forward to your response.


Thanks for the reply.
We have this situation:

  • we have a web application with integrated viewer
  • we have an entity, called “CARD”, which contains a document myfile.txt
  • user “A” displays the “card” with myfile.txt and makes a change to the document, or replaces it (keeping the same name)
  • user “B” displays the same “card”, but the document remains on the previous version

To solve this problem, we had to replace the file names with the generated guid each time the documents are displayed. In the temporary folder, a folder is created each time the same document is opened. In this way, we solve the problem above, but we lose the benefits of the cache. What is the right strategy to adopt in our case?




Thanks for providing the details.

It is important to inform you that prior to version 19.1 of GroupDocs.Viewer for .NET, the cache for a particular document was updated whenever the last modification date of that document was changed. This happens when you modify (and save) the file or when you replace the file with another file that has the same name but the different modification date. However, since version 19.1, the API no longer tracks the last modification date of the files and caching is done only once when the document is rendered for the first time. The cache never updates until the user updates it by himself. This change is done to reduce the number of calls to storage and improve the performance of the rendering when the caching is enabled.

In your case, a user may modify/update a particular document at any time and if the document already has the cached files, the API will fetch and display the previous version (cached content) of the document to other users. Therefore, you will have to implement your own logic to detect if the original document is modified or not. If it is modified, you will first clear the cache and then render the document, otherwise, you will simply render the document and get the cached content.

We have also prepared this sample console application for you to demonstrate how you can detect if a document is modified and then decide whether to read from the cache or regenerate the cache to get updated content. Hope it helps.



Please download the revised version of the sample console application that we have provided in the previous reply. In this version of the application, you will not have to keep the record of the last modification date of the document manually. Hope it helps.