Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

The GetUrlCacheEntryInfofunction lets you retrieve the INTERNET_CACHE_ENTRY_INFOstructure for the specified URL. This structure contains the structure size, URL of the cached data, local file name, cache entry type, use count, hit rate, size, last modified, expire, last access, and last synchronized times, header data and header data size, and file extension.

GetUrlCacheEntryInfoaccepts a URL, a buffer for an INTERNET_CACHE_ENTRY_INFOstructure, and the buffer size. If the URL is found, the data is copied into the buffer. Otherwise, the function fails and GetLastErrorreturns ERROR_FILE_NOT_FOUND. If the buffer size is insufficient to store the cache entry data, the function fails and GetLastErrorreturns ERROR_INSUFFICIENT_BUFFER. The size required to retrieve the data is stored in the buffer size variable.

GetUrlCacheEntryInfodoes not do any URL parsing, so a URL containing an anchor (#) is not found in the cache, even if the resource is cached. For example, if the URL http://example.com/example.htm#sample was passed, the function would return ERROR_FILE_NOT_FOUND even if http://example.com/example.htm is in the cache.

The following example retrieves the cache entry information for the specified URL by calling GetUrlCacheEntryInfo.

Copy Code
#define CACHE_ENTRY_BUFFER_SIZE  (1024*5)
DWORD dwBufferSize=0;
LPINTERNET_CACHE_ENTRY_INFO lpCacheEntry;
dwBufferSize = CACHE_ENTRY_BUFFER_SIZE;
//Allocate memory for the buffer that stores .
lpCacheEntry =
(LPINTERNET_CACHE_ENTRY_INFO)LocalAlloc(LPTR,CACHE_ENTRY_BUFFER_SIZE);
//Call  to retrieve cache data and specify the URL by passing a
pointer to the URL string in the 
lpszUrl parameter.
BOOL bValue =
GetUrlCacheEntryInfo(lpszUrl,lpCacheEntry,&dwBufferSize);

See Also

Concepts

Caching