Free Support Forum - groupdocs.com

Cache management

Hello,


I’m trying to implement GroupDocs.Viewer and Annotation in my project but i have some problems.

1) My documents will be in local db and i’ll open them from stream. Also there will be lots of documents and users. So temp folder will be too large. How can i manage cache and processing folder. Can i make like this, delete 10 mins or older documents in cache and processing folder.

Or disable cache.

2)When i try download document after make annotations as word doc, document downloaded without extention. Some users can’t figure this out. What can we do about this? Am i doing it not properly?

3) When i use text replacement tool, there is orange box with “Replace” text inside it looks like button but it doesn’t a button. Most users can think its a button and when hr/she click text will instantly change.(I can override it with css i think) and replace textbox looks like focused control always, even after you add another annotation. Also typewriter tool looks like focused always.

4) When i use text replacement tool and after that try to download document as pdf, text replacement doesn’t work.


Sorry for long post and thanks for help.

Kind regards,

Hello,


Thank you for your interest in GroupDocs.
1. Please investigate this documentation for how to manipulate with cache for the GroupDocs.Viewer
2. To download document with annotations please use this code:

Filename - variable with document name
------------
const string _groupdocsTemp = “Saaspose”;
long sessionId = Groupdocs.Web.Annotation.FileSessionMapper.Instance[Filename];
if (sessionId == 0)
{
throw new Exception();
}
string tempFileName = AnnotationsExporter.Perform(sessionId, Filename, DocumentType.Pdf, AnnotationMode.TrackChanges);
string tempFilePath = Path.Combine(Path.GetTempPath(), _groupdocsTemp, tempFileName);

return File(tempFilePath, “application/” + DocumentType.Pdf.ToString(), tempFileName);
-------------

3. Yes, you can override it with CSS.
4. Please try to download document with text replacement annotation with the code which we shared above

Hello Pavel,


I looked link for cache management but it doesnt what i want. I want to disable caching completely because we work with streams and in viewer cache folder there is cache and processing folder, processing folder has exactly same documents(Capture.png) with cache folder. If we could stop populating cache folder(or processing folder) it costs us %50 less storage space.

Hello,


Thank you for coming back. Unfortunately Viewer can’t work with our cache. But to save some free space and prevent cache size increasing you can clean it from time to time by using spacial method from the DocumentCache class. The method is: RemoveOldEntries(TimeSpan olderThan, string logFilePath = null)

For example:
cache.RemoveOldEntries(new TimeSpan(), @“c:\GDViewerTmp\cache_clean_log.txt”);

Thank you.

Viewer creates images for all pages before we see all pages. I think technicly viewer should create page caches when i want to see that spesific page. For example i have a word document(100 pages, 2 mb) when i want to open it, viewer creates cache for all pages when opening and their size about 133mb(Capture2.JPG). It’s way too much. I think viewer should create first two pages when opening. After that when i want to see 3th page, it should create cache for it. Because its already stores the original file(Capture.JPG). It can create cache from it.

Also i tried extra ordinary case that have 10.000 pages , about 9mb word document. I cant opening it. I canceled operation when viewer trying to create prossesing folder. After i canceled operation i looked cache folder size its about 1.35 gb (even it was create about 1500 pages.) and There will be over 50000(It creates 30000 images for cache and 30000 images for processing folder) pages

What should we do with this sutiation?

Hello,


Thank you for the question. Yes, you are right the cache created by the Viewer will take quite a lot of space. Unfortunately in current version of the Viewer you can’t do nothing with this. At this time our product team works on the brand new Viewer which will support custom storage provider and absolutely new system logic.

As for the release date of this new Viewer - sorry but currently I can’t share it with you.

Thank you.

Okay, thank you. One more question is there anyway to set timeout for viewer i mean forexamle “if document still loading after one minute, cancel operation” Can i do that?

Hello,


No, you can’t cancel operation but you can use work workaround. Please investigate attached JavaScript code:


This code will trigger each second “checkIsloaded” method which will check if the global flag “isLoaded " and increase “counter”. If the counter more than 1 (what means that the more that one second is passed) and the flag is steal false - document doesn’t loaded and the div with Viewer will be totally removed . Also this code sets the functional which will be called when the document is loaded - when it loaded the flag will be changed from false to true.

To integrate it in to your project you just need to change the max. counter value here: if (window.counter > 1 && window.isLoaded != true) - 1 is just an example

Also you should note next: this code will fully remove the Viewer from the page and then to view it again you need to refresh the page. This was done only as an example and you need to replace $(”#test").remove(); with your functional, which will do something else, for example show button “select another document”. Or make an ajax request which will remove the cache folder.

Thank you.