views:

1331

answers:

2

Hi

I'm using the WebBrowser control in .Net to execute some 3rd party affiliate marketing conversions.

I have a queue table in a database with all the scripts/images to execute. I loop through all these in a WinForms app with the WebBrowser control. After I've executed a script/image I Dispose the WebBrowser control, set it to null, and renews it with a new WebBrowser control instance.

Consider this URL: http://renderserver/RenderScript.aspx?id=1

RenderScript.aspx displays an Image with a URL of e.g.: http://3rdparty/img.ashx?id=9343

I use Fiddler to see all requests and responses, and when the same URL is executed twice, it uses some kind of cache. That cache exists underneath the WebBrowser control itself.

This cache means that the img.ashx is not called.

I tried using Internet Explorer to request the URL: http://renderserver/RenderScript.aspx?id=1 and hit F5. Then it is requested perfectly.

But if I click the address bar and hits Enter to navigate to the same URL again - it is not requested. When I use Firefox is will request the page and image everytime no matter if I use F5 or navigate from the address bar.

I found some Win32 API calls (http://support.microsoft.com/kb/326201) that was able to clear the cache. It worked on my local machine. Then the app was deployed to a server running Windows Server 2003 Standard x64 (my own machine is Vista x86).

And now the API calls to clear the cache doesn't work.

Any ideas on why the API calls doesn't work on Windows Server, but works on Vista? Both machines running IE8.

A: 

Fiddler uses fundamentally the same code as in the KB article to clear the WinINET cache, and I use it on Win2k3 every day.

Rather than wiping the user's entire cache, the proper fix is to set the proper HTTP response header to forbid caching. You can learn more about WinINET caching here: http://www.enhanceie.com/redir/?id=httpperf

(Alternatively, you could simply add a randomized query-string parameter; that way, each time the control encounters a request for the resource, the URL is different and the cache is thus automatically bypassed.)

EricLaw -MSFT-
Negative. It has nothing to do with cache headers. They're already set correctly to avoid caching. And other browsers are not caching, as I pointed out.
MartinHN
And the randomized parameter doesn't work either. Because the 3rd party HTML that is loaded up by the ScriptRender page is completely out of my control. So I can only add the parameter to the RenderScript page. The image tag (sometimes IFrame, sometimes javascript), is loaded with the static URL.
MartinHN
Sorry, but you are mistaken. WinINET/IE/WebOCs will not reuse cached responses if the appropriate response headers are set. What are the exact headers the ASHX sends? Can you send me a Network Capture (www.fiddlercap.com)?
EricLaw -MSFT-
A: 

... nevermind ..

xxx