Search code examples
winformscefsharp

Is it possible to delete specific pages from the CEF cache?


Consider this scenario:

  1. in Search mode, the program performs a search for a given word in local html files and displays a list of links to the found files.
  2. on click on a link, the file is read to memory, the found words are marked using HAP and the modified html is fed to the CefSharp browser.
  3. after exiting Search mode, in Browsing mode, the browser will pull the same file from the cache and display it, markings and all, which may or may not be desirable.

So the question is: can those marked files be deleted from the cache when exiting Search mode?

Thank you.


Solution

  • I couldn’t make work the CromeDevTools way that was suggested here (although I confess I didn’t spend much time on it) so here is my ugly solution: Maintain a List of all the marked files during Search mode. In browsing mode, check if the target file is in the list and if it is (meaning that it was marked) just read it afresh from disc to a HtmlDocument in memory and feed it to the browser, thus bypassing the cache.