Exploring the URL Cache



Click here for a larger image.

Environment: VC6, WTL 7.0, WinXP

My desire to create one button to blow away all files left on my machine from my browser led me down the path of the URL Cache. This seems to be the place where all Internet-related files are managed. Of course, this journey turned into a full-blown application caused me to look into the cache and view the details of what's actually kept there.

All methods to manipulate the URL cache are a part of the WinInet library. This library is fairly low-level (not quite at the socket level, but it's pretty far down there). In addition to the cache, the library also provides HTTP, FTP, and Gopher file transfer functionality.

Walking the URL cache is very similar to using the Win32 file-realted functions. FindFirst (with some parameters) returns a handle, FindNext (until there are no more), that sort of thing. I developed a set of classes to deal with the nitty-gritty. You'll find these in the UrlCacheUtil.h/.cpp file.

The application is fairly self documenting (famous last words). I'll leave it to you get out of it what you want. The detail dialog is modless, so it can be left up as you scroll through the cache entries.

Some interesting notes:

  • There are definitely some undocumeneted CacheEntryTypes being used. I suspect IE creates some for its own internal use.
  • The groups are somewhat a mystery to me. I haven't come across one with a name yet. I suspect all entries go into an unnamed group by default.

Downloads

Download demo project - 39 Kb
Download source - 26 Kb


Comments

  • Help!Unable to compile the program

    Posted by bjam on 08/19/2010 02:39am

    When I try to compile the program I get the following type of errors. 
    Does anyone know what I need to do to get this program to compile in Visual VC++ 6.0
    
    --------------------Configuration: UrlExplr - Win32 Debug--------------------
    Compiling...
    UrlCacheUtil.cpp
    (91) : error C2061: syntax error : identifier 'LPINTERNET_CACHE_GROUP_INFO'
    (92) : error C2061: syntax error : identifier 'LPINTERNET_CACHE_GROUP_INFO'
    (92) : error C2535: '__int64 *__thiscall CUrlCacheGroup::Next(void)' : member function already defined or declared
    (89) : see declaration of 'Next'
    (299) : error C2039: 'FindFirstUrlCacheGroup' : is not a member of '`global namespace''
    (299) : error C2065: 'FindFirstUrlCacheGroup' : undeclared identifier
    \UrlCacheUtil.cpp(299) : error C2440: '=' : cannot convert from 'int' to 'void *'
    Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
    UrlCacheUtil.cpp(318) : error C2039: 'FindNextUrlCacheGroup' : is not a member of '`global namespace''
    UrlCacheUtil.cpp(318) : error C2065: 'FindNextUrlCacheGroup' : undeclared identifier
    UrlCacheUtil.cpp(330) : error C2061: syntax error : identifier 'LPINTERNET_CACHE_GROUP_INFO'
    UrlCacheUtil.cpp(332) : error C2065: 'dwFilter' : undeclared identifier
    UrlCacheUtil.cpp(336) : error C2065: 'INTERNET_CACHE_GROUP_INFO' : undeclared identifier
    UrlCacheUtil.cpp(337) : error C2065: 'pInfo' : undeclared identifier
    UrlCacheUtil.cpp(338) : error C2039: 'GetUrlCacheGroupAttribute' : is not a member of '`global namespace''
    UrlCacheUtil.cpp(338) : error C2065: 'GetUrlCacheGroupAttribute' : undeclared identifier
    UrlCacheUtil.cpp(338) : error C2065: 'CACHEGROUP_ATTRIBUTE_GET_ALL' : undeclared identifier
    UrlCacheUtil.cpp(344) : error C2061: syntax error : identifier 'LPINTERNET_CACHE_GROUP_INFO'
    UrlCacheUtil.cpp(345) : error C2084: function '__int64 *__thiscall CUrlCacheGroup::Next(void)' already has a body
    UrlCacheUtil.cpp(346) : error C2264: 'Next' : error in function definition or declaration; function not called
    UrlCacheUtil.cpp(551) : error C2668: 'First' : ambiguous call to overloaded function
    UrlCacheUtil.cpp(556) : error C2264: 'Next' : error in function definition or declaration; function not called
    UrlCacheUtil.cpp(567) : error C2065: 'CACHEGROUP_FLAG_FLUSHURL_ONDELETE' : undeclared identifier
    Error executing cl.exe.
    
    UrlCacheUtil.obj - 21 error(s), 0 warning(s)

    Reply
  • URL Explorer

    Posted by Legacy on 06/16/2003 12:00am

    Originally posted by: Craig Russell

    Trying to inject (plagiarise) some of your code into my own I appear to be missing 'UrlHist.h'. Perhaps I am being a bit thick but, when I compile my app (not remotely contravening your copyright :-)), it does fall over whilst trying to clear the history. It also leaves some cookies behind.

    Personally I'd send me a bill for these dumb-arse questions but what can you do?

    Can you post or am I not seeing the bigger picture?

    Thanks in eager anticipation...

    ps what's the deal with your email address?

    Reply
  • It's great ! But "Could not find the file atlres.h."

    Posted by Legacy on 05/31/2003 12:00am

    Originally posted by: Thien Ly

    it's great! But when i compile program. There is a error "Could not find the file atlres.h"?. Where to see it? 
    

    Reply
  • Cleared history works, but ghost items remain displayed in listing

    Posted by Legacy on 05/30/2003 12:00am

    Originally posted by: chris

    I can do a clear all history, and it does in fact remove all history items in Internet Explorer's panel. However, when the utility refreshes, it displays some old URLs as if they are still in the history. Very weird. Some of the URLs are from months ago, not sure where they are coming from.

    Any idea how to fix this so after a "clear all" it doesn't display these ghost items?

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • On-demand Event Event Date: January 7, 2015 The Flash Visionary Chat series of webinars brings together IT and business leaders as well as thought leading industry analysts to discuss how the flash revolution is eradicating inefficiency, unleashing innovation, and accelerating businesses. Join us for this episode where we are excited to host not only the 451 Research, who share their recent industry research, but also one of our top customers, who will share their perspective on the disruptive power of flash …

  • Intelligent N+X Redundancy, Placement Affinities, & Future Proofing in the Virtualized Data Center Virtualization brought about the ability to simplify business continuity management in IT. Workload portability and data replication capabilities mean that physical infrastructure failures no longer need impact application services, and they can rapidly be recovered even in the event of complete site failure. However, Enterprises and Service Providers face new challenges ensuring they have enough compute …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date