Share via


Retrieving Cache Entry Data

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

The GetUrlCacheEntryInfo function lets you retrieve the INTERNET_CACHE_ENTRY_INFO structure 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.

GetUrlCacheEntryInfo accepts a URL, a buffer for an INTERNET_CACHE_ENTRY_INFO structure, and the buffer size. If the URL is found, the data is copied into the buffer. Otherwise, the function fails and GetLastError returns ERROR_FILE_NOT_FOUND. If the buffer size is insufficient to store the cache entry data, the function fails and GetLastError returns ERROR_INSUFFICIENT_BUFFER. The size required to retrieve the data is stored in the buffer size variable.

GetUrlCacheEntryInfo does 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 https://example.com/example.htm\#sample was passed, the function would return ERROR_FILE_NOT_FOUND even if https://example.com/example.htm is in the cache.

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

#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