Free Support Forum - groupdocs.com

Group Docs v3.3 - Cache Removal Utility

Hi Team,

As per the release note of v3.3 following new feature is included.
VIEWERNET-459 Provide remove old cache utility feature in the next generation API

I have created one sample console application and added following line of code but its not removing cache/old enteries.

//Set License key
vsLicenceFile = ".\\GroupDocs\\GroupDocsViewer.lic";
License lic = new License(); // License Key
lic.SetLicense(vsLicenceFile);

//Init viewer config
ViewerConfig viewerConfig = new ViewerConfig();
viewerConfig.StoragePath = @"D:\CFP\v3.3\WebForm_Front_End\GroupDocs.Viewer.WebForm.FrontEnd\App_Data\Temp";

// Init viewer image or html handler
ViewerHtmlHandler viewerHTMLHandler = new ViewerHtmlHandler(viewerConfig);

//Clear all cache files
viewerHTMLHandler.ClearCache();

Please let me know, am I missing anything.

Thanks,
[Parth Patel]

Hi Patel,


Thanks for posting your query.

You are facing issue because of the incorrect storage path. Please remove “\Temp” portion in the path as ClearCahe() function accepts only storage path and automatically detects temp folder in it. Please try this and share your experience.


Best Regards


Hi Aziz,

Thanks for quick response. I think its working fine now.

In viewer config we are setting different paths -
StoragePath
TempPath
CachePath

While deleting cache which path internally ClearCache method is using?

Thanks,
[Parth Patel]

Hi Patel,


Good to know that its working fine now.

Please note that ClearCache() method uses StoragePath to remove the cached files. If you have any further questions, please let us know.


Warm Regards
Hi Aziz,

I have verified this in detail. Please see ViwerConfig details for example which I have tested.

ViewerConfig viewerConfig = new ViewerConfig
{
StoragePath = @"D:\v3.3\WebForm_Front_End\GroupDocs.Viewer.WebForm.FrontEnd\App_Data",
TempPath = @"D:\v3.3\WebForm_Front_End\GroupDocs.Viewer.WebForm.FrontEnd\App_Data\temp",
UseCache = true,
CachePath= @"D:\v3.3\WebForm_Front_End\GroupDocs.Viewer.WebForm.FrontEnd\Cache"
};

When I am executing ClearCache() method its deleting files from Cache Path folder.

Please could you confirm this once again. How this is working?

If my ViwerConfig is having following details, its not at all working. Why?
ViewerConfig viewerConfig = new ViewerConfig
{
StoragePath = @"D:\v3.3\WebForm_Front_End\GroupDocs.Viewer.WebForm.FrontEnd\App_Data",
TempPath = @"D:\v3.3\WebForm_Front_End\GroupDocs.Viewer.WebForm.FrontEnd\App_Data\Cache",
UseCache = true
};

Please let me know your comments.

Thanks,
[Parth Patel]


Hi Patel,


Thanks for posting detailed information about your issue.

Before explaining the issue, let me elaborate the working of Cache folder in the API so that you would have a clear picture in your mind.

When the CachePath is not set in configuration then the API uses temp folder as a default cache directory and keeps the documents in this folder. In case you set cache path i-e config.CachePath = “D:/Data/Storage/Cache”, it will use that Cache folder for caching files.

Now, let me explain the two code scenarios you have mentioned in the post.

ViewerConfig viewerConfig = new ViewerConfig
{
StoragePath = @“D:\v3.3\WebForm_Front_End\GroupDocs.Viewer.WebForm.FrontEnd\App_Data”,
TempPath = @“D:\v3.3\WebForm_Front_End\GroupDocs.Viewer.WebForm.FrontEnd\App_Data\temp”,
UseCache = true,
CachePath= @“D:\v3.3\WebForm_Front_End\GroupDocs.Viewer.WebForm.FrontEnd\Cache”
};

In this case, CachePath is set and API will use this folder to keep cache files. Whenever cache removal function will be called, it will remove files from D:\v3.3\WebForm_Front_End\GroupDocs.Viewer.WebForm.FrontEnd\Cache folder.


ViewerConfig viewerConfig = new ViewerConfig
{
StoragePath = @“D:\v3.3\WebForm_Front_End\GroupDocs.Viewer.WebForm.FrontEnd\App_Data”,
TempPath = @“D:\v3.3\WebForm_Front_End\GroupDocs.Viewer.WebForm.FrontEnd\App_Data\Cache”,
UseCache = true
};

In this case, CachePath is not set and API will use temp folder as a default cache directory. Whenever cache removal function will be called, it will remove files from default cache directory D:\v3.3\WebForm_Front_End\GroupDocs.Viewer.WebForm.FrontEnd\App_Data\temp.

If you have any further questions, please let us know.

Warm Regards