Rectangle 27 0

delphi How to always load a fresh page in TWebBrowser?


DLCTL_PRAGMA_NO_CACHE
Navigate2()
typedef enum BrowserNavConstants {
    navOpenInNewWindow = 0x1,
    navNoHistory = 0x2,
    navNoReadFromCache = 0x4,
    navNoWriteToCache = 0x8,
    navAllowAutosearch = 0x10,
    navBrowserBar = 0x20,
    navHyperlink = 0x40,
    navEnforceRestricted = 0x80,
    navNewWindowsManaged = 0x0100,
    navUntrustedForDownload = 0x0200,
    navTrustedForActiveX = 0x0400,
    navOpenInNewTab = 0x0800,
    navOpenInBackgroundTab = 0x1000,
    navKeepWordWheelText = 0x2000,
    navVirtualTab = 0x4000,
    navBlockRedirectsXDomain = 0x8000,
    navOpenNewForegroundTab = 0x10000
} BrowserNavConstants;

Alternatively, you might consider switching to TEmbeddedWB, which handles the browser customization for you, and has a DownloadOptions property that accepts DLCTL... flags, including DLCTL_PRAGMA_NO_CACHE.

As you can see, DLCTL_PRAGMA_NO_CACHE is not on that list. It is actually a flag you specify as an output value when implementing a handler for the browser's DISPID_AMBIENT_DLCONTROL property. Read the MSDN documentation:

Flags [in] A pointer to a VARIANT of type VT_I4 or VT_I2 that specifies a combination of the values defined by the BrowserNavConstants enumeration.

In VCL, TWebBrowser is a wrapper for Internet Explorer, specifically the IWebBrowser2 interface.

So you would have to implement a custom IDispatch object and hook it into IWebBrowser2 in order to use DLCTL_PRAGMA_NO_CACHE correctly.

TWebBrowser wraps the IWebBrowser2 interface from Microsoft's Shell Doc Object and Control Library (SHDOCVW.DLL) to allow you to create a customized Web browsing application or to add Internet, file and network browsing, document viewing, and data downloading capabilities to your applications.

The WebBrowser Control gives you control over what it downloads, displays, and executes. To gain this control, you need to implement your host's IDispatch so it handles DISPID_AMBIENT_DLCONTROL. When the WebBrowser Control is instantiated, it will call your IDispatch::Invoke with this ID. Set pvarResult to a combination of following flags, using the bitwise OR operator, to indicate your preferences. ... DLCTL_RESYNCHRONIZE and DLCTL_PRAGMA_NO_CACHE: These flags cause cache refreshes. With DLCTL_RESYNCHRONIZE, the server will be asked for update status. Cached files will be used if the server indicates that the cached information is up-to-date. With DLCTL_PRAGMA_NO_CACHE, files will be re-downloaded from the server regardless of the update status of the files. ...

Note
Rectangle 27 0

delphi How to always load a fresh page in TWebBrowser?


procedure TForm2.Button2Click(Sender: TObject);
var
  Flags: OLEVariant;

begin
  Flags:=4; //NavNoReadFromCache
  WebBrowser1.Navigate('http://www.ghisler.com/', Flags);
end;

Since I use www.ghisler.com (counter is at bottom) I can use

We all LOVE Ghisler!!!!!!!! Don't we? Total Commander is definitively and without doubt my favorite program. Mr. Ghisler, one million thanks for that jewellery. Maybe Embarcadero can learn something from him (like software without bugs IS possible).

and it works perfectly (Delphi XE7). I see TC main page, click on hyperlink then on Button2 again and counter is new. When I use Navigate(URL) only, counter is still the same.

Note