Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TWebBrowser check cache?

Status
Not open for further replies.

AP81

Programmer
Apr 11, 2003
740
AU
Hi,

I have a billboards App which takes X number of URLs and displays them (rotates through them one-at-a-time) using a TWebBrowser component.

This works great, except that once the TWebBrowsers has loaded a URL it always uses whats in Internet Explorer's cache for every subsequent load (until a reboot). For example, a couple of images may have changed in the remote URL but the TWebBrowser component will not show these changes and use what is in the cache instead.

The obvious solution is to tell the TWebBrowser to not load from cache at a specified interval, i.e.
Code:
var
  Flags: OLEVariant
begin
  Flags := 4; //NavNoReadFromCache
  WebBrowser1.Navigate(NEXT_URL,Flags);
end;

This is not really a great solution, as some of these URLs have 5MB+ of images. Downloading the page every 5 minutes will use up a lot of download, especially if run over any period of time.

Any ideas on how I can tell whether the URL I am viewing from cache is different to the remote URL?

Thanks in advance.
 
Even if you manage to interrogate the remote web server to determine if the images/HTML have different modified date/times, it may not help. ISPs often use transparent proxy servers and the like the invisibly cache files for you anyway - you'd only be checking against the proxy server.

To be safe - I'd recommend setting a var to the current date/time (Now()) and checking the time diff (HoursBetween(...)) and setting Flags (and resetting the stored date/time) only after an hour or so to minimize how often the images are downloaded.
 
Yeah, I was kind of thinking that my options are limited here.

Some people want to use this application to display web pages in Nightclubs on their TVs. The problem with this it that they want live content... i.e., edit the web page and the next billboards cycle displays the newly updated page.

This is my problem...If I am checking every 5,10,15+ minutes there is a big chance that the content will not be displayed accordingly.

I guess I may have to go down the client/server path as I don't think I have any more options here.

Thanks.
 
Have a look at Item #12: HTTP GET. (Freeware with source.) this little gem has the option to download images or pages, with or without cache.

I would suggest running it as a background process, while your "slide-show" is running in the foreground. Have HttpGet keep downloading to a folder, then open your slides from that folder. That folder them becomes your own cache, so to speak, and you'll know they are fresh.

You might want to do it in stages to avoid conflict with unfinished downloads, like seperate DL folder and a cache foder. HttpGet with tell you it's done then move it to your cache folder if different.

I've learned quite a bit by picking through the included source. Even thought its quite old, the author of UtilMind deserves much credit.

Roo
Delphi Rules!
 
Hi roo0047,

That is what I was tring to do, but I realised that this is just not feasible.

A client may configure any URL into this slide show, it could be a small basic web page, or it could even be something like microsoft.com (not that they would).

Given that I don't have any idea of what or where any media on the web page is located, I can't just grab all the images/media and save them to file.

I could use DOM to search the page, but this just seems way too messy and not reliable enough (seeing as pages my have javascript, and may have images/media hosted on other servers).

Thanks for trying though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top