Discussion:
InternetOpenUrl reads from cache
(too old to reply)
Joby Larsen
2004-12-05 02:00:56 UTC
Permalink
My program needs to read a web page that gets updated every minute or so.
After reading the file the first time, it just goes back to the cache on
subsequent reads. My copy never gets updated. The only way I can force the
program to go to the web is to use IE to delete the local cache.

The function call I am using
hSource = ::InternetOpenUrl(mhInternet,Source,NULL,0,INTERNET_FLAG_RELOAD |
INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_PRAGMA_NOCACHE,(DWORD_PTR)&Token);

The program will read the updates of another similar site correctly, but not
this one. Is there anything I can do to force the function to ignore the
cache? Is there something I don't know about?

I suppose I could call DeleteUrlCacheEntry(), but it all seems rather silly
when it shouldn't be caching anything to start with, and even if it did,
should be ignoring the cache and reloading the page.
Stephen Sulzer
2004-12-07 04:57:32 UTC
Permalink
That is pretty weird. The RELOAD flag should force WinInet to load the web
page from the server and not from the cache, and the DONT_CACHE flag tells
WinInet to not write the downloaded page to the cache. You should not need
to do anything else to ensure that WinInet bypasses the cache.

When you clear the IE cache and resend the request--with the RELOAD and
DONT_CACHE flags given to InternetOpenUrl--can you confirm that WinInet is
actually writing the page to the cache?

What is the version stamp on your WININET.DLL file?

Is your request going through a proxy server?

What does the HTTP response (status code + headers) for this web page look
like? (You can use HttpQueryInfo with HTTP_QUERY_RAW_HEADERS_CRLF to obtain
all the response headers.)

The only thing I can think of that might make a difference is to rework your
code to use InternetConnect/HttpOpenRequest/HttpSendRequest instead of
InternetOpenUrl.

Stephen
Joby Larsen
2004-12-08 08:22:41 UTC
Permalink
My Wininet.dll is version 6.0.2600.0
I don't know how to directly confirm that it is writing to the cache, but
the indirect evidence is fairly strong (no network activity on subsequent
calls, use IE to delete temporary internet files forces a reload, etc).

I don't use a proxy.

The following header info was obtained from Proxomitron (this behaviour
occurs whether or not I run Proxomitron)

HTTP/1.0 200 OK
Server: Microsoft-IIS/5.0
Date: Wed, 08 Dec 2004 08:12:02 GMT
Content-Type: text/html
Accept-Ranges: bytes
Last-Modified: Wed, 08 Dec 2004 08:06:04 GMT
ETag: "4eb665c3fcdcc41:be2"
Content-Length: 8544

For comparison, another site which refreshes correctly includes the header
"Pragma: no-cache".

HTTP/1.0 200 OK
Transfer-Encoding: chunked
Date: Wed, 08 Dec 2004 08:13:05 GMT
Allow: GET, HEAD
Server: Oracle_Web_Listener/4.0.8.2.4EnterpriseEdition
Content-Type: text/plain
Pragma: no-cache
Cache-Control: no-cache
Content-length: 927
Connection: Keep-Alive
Keep-Alive: timeout=10, max=999

These are the only 2 sites that I read that are being updated on a regular
and frequent basis.

I am now issuing a DeleteUrlCacheEntry() fuction call immediately after
reading the file, and it works OK. But it all seems unnecessary.
Post by Stephen Sulzer
That is pretty weird. The RELOAD flag should force WinInet to load the
web page from the server and not from the cache, and the DONT_CACHE flag
tells WinInet to not write the downloaded page to the cache. You should
not need to do anything else to ensure that WinInet bypasses the cache.
When you clear the IE cache and resend the request--with the RELOAD and
DONT_CACHE flags given to InternetOpenUrl--can you confirm that WinInet
is actually writing the page to the cache?
What is the version stamp on your WININET.DLL file?
Is your request going through a proxy server?
What does the HTTP response (status code + headers) for this web page
look like? (You can use HttpQueryInfo with HTTP_QUERY_RAW_HEADERS_CRLF
to obtain all the response headers.)
The only thing I can think of that might make a difference is to rework
your code to use InternetConnect/HttpOpenRequest/HttpSendRequest instead
of InternetOpenUrl.
Stephen
Continue reading on narkive:
Search results for 'InternetOpenUrl reads from cache' (Questions and Answers)
4
replies
How do you make a program access the internet?
started 2011-01-10 13:30:09 UTC
programming & design
Loading...