Free Support Forum -

Set max cache size (.NET)


How do you set a maximum cache size using the .net library. I am unable to find this in the documentation. Thanks.


Hello Matt,

Can you please clarify your question? What cache size limit you mean? If you’re asking about limiting a total size of the “temp” folder - currently GroupDocs.Viewer doesn’t have such functionality, and it is very strange at all. For example, what the GroupDocs.Viewer should do, if maximum cache size is reached, and new document should be opened, which was not cached before?

There is a “RemoveOldEntries” method, which allows you to remove the obsolete cache, maybe you’re looking for this?

If you will have more questions please feel free to contact us.


OK, yea i already setup RemoveOldEntries to clear things out older than a certain time. Thanks.



Is it possible to Remove all folders that are currently not in use, i.e. files that are not currently opened in Viewer by some user on website?

Thank you.


Hello Deric,

Thank you for the question. Yes, you can remove such folders and files. In case that you need to delete to files which are not in the “temp” folder you should use common .NET functional. If you need to delete the cache of the Viewer (folder “temp”) you can use features of the Viewer. For more info about how to remove the cache please check this article , “Removes old cache entries.” section.

Thank you.


the [“RemoveOldEntries” method] does not remove files in the ["\temp\S"] folder. These are files created by the Stream feature of the GroupDocs.Viewer.
The RemoveOldEntries currently only removes entries in the [processing] folder and the [cahce] folder. Can this be fixed to delete entries in [\S] folder as well?

I am rendering a lot of files from Streams.
Is there way to remove the files in the [\S] folder??? or have it autodelete the file after the stream is rendered?

Please advise,



We are sorry to hear that you have such trouble. For example we use such code to delete old cache files and it remove cache of the stream as well. Please note that the: Server.MapPath("~/testfiles") in the “DocumentCache” class decliration is a root storage where the “temp” folder of the Viewer will be.

If this will not help you please share with us screenshot of the folder structure and code that you use - we will check it and help you to resolve the issue.

Best regards.


I did likeu said in the screen added
var documentcache = new DocumentCache("~/GroupDocLicense/GroupDocs.Viewer.lic", “~/testfiles”);
documentcache.RemoveOldEntries(new TimeSpan(1, 2, 0));

but it does not delete the cache. I am using .net viewer 2.16.

please help…the cache is not deleting… please see attached code,.


Hi Alex,

Thank you for the code example. I have checked and fixed it for you. Please download it here . Also you should note that “RemoveOldEntries” method will delete only files from the cache folders, it means that folders such as: “S”, “Cache” and “Processing” will not be deleted , they will be empty.

Best regards.



I donwloaded your code, and everything is the same. Did the DLL change???
nothing is deleted.

BTW, i need it to remove thefile in the “S”, “Cache” and “Processing” folders.
The stream creates a new entry for the same file each time it is view. (a lot of junk file created fast)
I want to delete all files, or at least delete the stream file and all the temp files for the stream.

I need the RemoveOldEntries to delete files in the “S”, “Cache” and “Processing” folders.
Is this possible?
the folders get filled up fast…I view a few files and i got 240Megs of temp files.
This is not going to work for me. I need to remove all the temp files for the stream.

please advise.


Nevermind. I got your code to work.
everything works.

I was missing the Server.MapPath("~/testfiles").

thx much for all your help.

BTW, can you add a flag/feature to delete the specific cache files belonging to the current stream, when the view is done rendering the stream? it would be nice to have the stream temp files delete automatically when the stream is done rendering in the view.



Thank you for the coming back and glad to hear that all works well now. We will investigate proposed improvement and if it will be possible we will add it to our roadmap.

Best regards.