Passing a URL to a HTMLViewer I load the site. After in the same HTMLViewer insert another site, but they are the images of the previous … Is there a way to clear the cache in HTMviewer?
i wonder if you can use the following to disable caching
I’m sort of wondering the same thing as this doesn’t happen on mac.
For example I’m changing images but keeping the same html code and it reflects the image of the original. Even though if I were to open the html file in a normal web browser it reflects the correct image.
I’m using webkit as the viewer.
Let me know if you found an answer to this @Stefano Basile
Found a VB method on the Microsoft site. Maybe it could be translated into Xojo ?
How to clear the cache when your application hosts a WebBrowser control
http://support.microsoft.com/kb/311289/en-us
For WebKit renderer only
You can try this… Either create a subclass of a HTMLViewer control and add this method:
[code]Sub ReloadFromOrigin()
#if TargetCocoa
Declare Sub reload Lib “Cocoa” Selector “reloadFromOrigin:” (id As Integer, sender As Integer)
reload me.Handle, me.Handle
#elseif TargetLinux
webkit_web_view_reload_bypass_cache(gtk_bin_get_child(me.Handle))
#elseif TargetWin32
DIM aMemoryBlock As MemoryBlock = Ptr(me.Handle)
DIM reloadDelegate As NEW CefReloadIgnoreCache(aMemoryBlock.Ptr(44))
reloadDelegate.Invoke(aMemoryBlock)
#endif
End Sub[/code]
or create a module and add this as a global method
[code]Sub ReloadFromOrigin(Extends viewer As HTMLViewer)
#if TargetCocoa
Declare Sub reload Lib “Cocoa” Selector “reloadFromOrigin:” (id As Integer, sender As Integer)
reload viewer.Handle, viewer.Handle
#elseif TargetLinux
webkit_web_view_reload_bypass_cache(gtk_bin_get_child(viewer.Handle))
#elseif TargetWin32
DIM aMemoryBlock As MemoryBlock = Ptr(viewer.Handle)
DIM reloadDelegate As NEW CefReloadIgnoreCache(aMemoryBlock.Ptr(44))
reloadDelegate.Invoke(aMemoryBlock)
#endif
End Sub[/code]
and then add these external methods:
Private Soft Declare Function gtk_bin_get_child Lib "libgtk" (bin As Integer) As Integer
Private Soft Declare Sub webkit_web_view_reload_bypass_cache Lib "libwebkitgtk-1.0.so" (web_view As Integer)
and this delegate
Private Delegate Sub CefReloadIgnoreCache(pointer As Ptr)
Thanks to Christian for help with the Windows declares…
Thank you for posting this as I’m just a beginner with this. When would you call ReloadfromOrigin? I tried calling it after loading the html however on windows I get an error.
If I call the method via a button then it works fine. Am I doing something wrong?
DIM reloadDelegate As NEW CefReloadIgnoreCache(aMemoryBlock.Ptr(44))
This is where debugger catches the error and says NilObjectException
If you added everything properly, you would just call “Viewer.ReloadFromOrigin”
Thanks @shao sean after looking at my code it was user error. Thanks for your help and it works as advertised.