DelphiFAQ Home Search:

Programmatically clear Internet Explorer's cache


comments14 comments. Current rating: 4 stars (3 votes). Leave comments and/ or rate it.


I need a tool to empty IE's cache on a regular basis. How can I quickly write that myself?


You can use a quick and dirty approach if you need to delete the cache only on one specific computer. In this case write a batch file that contains the following statements (replace 'administrator' with your user name):

del "c:\Temp\*.*" /ARSAH /s /q
del "c:\documents and settings\administrator\Recent\*.*" /s /q /a
del "c:\documents and settings\administrator\History\*.*" /s /q /a
del "c:\documents and settings\administrator\Temporary Internet Files\*.*" /s /q /a

If you want a more universal tool then look at the following Delphi code. You can also download the compiled executable here: Del_IE_Cache.exe (8 kB)

program Delete_IE_Cache;


  Name:       DeleteIECache
  Parameters: -
procedure DeleteIECache;
  lpEntryInfo: PInternetCacheEntryInfo;
  hCacheDir: LongWord;
  dwEntrySize: LongWord;
begin { DeleteIECache }
  dwEntrySize := 0;

  FindFirstUrlCacheEntry(nil, TInternetCacheEntryInfo(nil^), dwEntrySize);

  GetMem(lpEntryInfo, dwEntrySize);

  if dwEntrySize>0 then
    lpEntryInfo^.dwStructSize := dwEntrySize;

  hCacheDir := FindFirstUrlCacheEntry(nil, lpEntryInfo^, dwEntrySize);

  if hCacheDir<>0 then
      FreeMem(lpEntryInfo, dwEntrySize);
      dwEntrySize := 0;
      FindNextUrlCacheEntry(hCacheDir, TInternetCacheEntryInfo(nil^), dwEntrySize);
      GetMem(lpEntryInfo, dwEntrySize);
      if dwEntrySize>0 then
        lpEntryInfo^.dwStructSize := dwEntrySize;
    until not FindNextUrlCacheEntry(hCacheDir, lpEntryInfo^, dwEntrySize)
  end; { hCacheDir<>0 }
  FreeMem(lpEntryInfo, dwEntrySize);

end; { DeleteIECache }



2006-07-10, 18:35:11
[hidden] from Australia  
The above Delphi code when executed causes ebay and various other on-line subscription services to forget who I am. Seems to me it must be doing more than just clearing the cache. I think it's wiping out my cookies which is exactly what I didn't want to happen.

2. 'My' XP system does not have the subdirectories mentioned in the above batch file.
2007-01-29, 05:31:09
anonymous from India  
I need to delete files from the internet explorer each time i call an action to view my latest graph charts that i am creating at runtime in HTL page.
Please guide me how can i delete the interent files programmaticaaly.
2008-04-16, 07:01:48
anonymous from Nigeria  
I'm hosting an online application that displays videos. I need the users browser to pick up the latest videos.
2009-07-09, 11:49:51
anonymous from Switzerland  
To prevent the deletion of cookies too, insert the following if-statement:

if lpEntryInfo^.CacheEntryType and COOKIE_CACHE_ENTRY = COOKIE_CACHE_ENTRY then

The constant COOKIE_CACHE_ENTRY should have the value $00100000.
2012-11-09, 21:12:14 from China  
Pasdfmdbfgj1110     4
http://www.texanslo..-6_24.html     J J Watt Jersey     James Jones Jersey     James Starks Jersey
http://www.official..-6_22.html     Jason Pierre Paul Jersey
http://www.authenti.._c_423_444     Jay Cutler Jersey     Jermichael Finley Jersey
http://www.baltimor..-6_20.html     Jimmy Smith Jersey
http://www.baltimor..-6_21.html     Joe Flacco Jersey     John Kuhn Jersey
http://www.texanslo..-6_26.html     Johnathan Joseph Jersey
http://www.authenti.._c_423_445     Johnny Knox Jersey     Jordy Nelson Jersey
http://www.authenti.._c_423_447     Julius Peppers Jersey
http://www.custom49..-7_28.html     Justin Smith Jersey
http://www.official..-6_24.html     Justin Tuck Jersey
http://www.official..-6_25.html     Kenny Phillips Jersey
2012-11-14, 23:21:35
anonymous from United States  
The CXHqwwe1115 Israeli position <a href=' http://www.wholesal..;Wholesale NFL Jerseys</strong></a> paper, a copy <a href=' http://www.wholesal..g>Cheap NFL Jerseys</strong></a> of which has been <a href='>NFL Jerseys Wholesale</strong></a> obtained by the BBC, is <a href=' http://www.topjerse..Customized Jerseys NFL</strong></a> intended for use in internal discussions and has <a href=' http://www.customje..>Custom NFL Jerseys</strong></a> not been endorsed by Foreign<a href=''> <strong> http://www.wholesal..</a> Minister Avigdor Lieberman.
2012-11-22, 00:54:45
anonymous from United States  
2013-01-05, 01:27:21
anonymous from China  
<a href=' http://www.wonderfu..>ibeats earphones</a> is characterized by its solid housing,sllyjfdibeats balanced sound quality and purest sound producing.<a href=';Monster Beats headphones</a>,<a href=' http://www.perfect-..</a> come out,<a href=' http://www.perfect-..'>Beats Studio Limited Edition</a> will give you a big surprise!bring the gospel to the vast number of music lovers. Monster Ibeats have Solid metal housing resists vibrations for purest sound without sonic side effects ControlTalk on-cable mic for convenient hands-free calling with iPhones and smartphones ControlTalk track seeking capabilities without touching your iPod or music phone. This <a href=' http://www.wonderfu..>ibeats earphones</a> unlike ordinary in-ear headphones,ibeats earphones are constructed from solid metal housing.With the <a href=' http://www.hotmusic..'>beats by dre mixr</a>, you can freely enjoy the beautiful music without being disturbed by the outside noise.We supply all kinds of beautiful Monster <a href=' http://www.wonderfu..'>Beats by dre</a>, such as ibeats earphones,<a href=' http://www.wonderfu..l'>solo hd bluetooth</a>,<a href=' http://www.hotmusic..'>beats studio headphones</a> and <a href=' http://www.hotmusic..>purple beats by dre</a>
2013-02-26, 21:55:58
2013-06-19, 02:03:48
anonymous from United States  
Board diagnostics (OBD) system <a href=''>MB Star C3</a>has come a very long way to go, because in the early 1980s. OBD easy access to health status information to the owners of<a href=' '>Autocom</a> vehicles. This also makes the work of the mechanic is very easy to find, if any. In earlier versions, only a specific part of the failure can be reported through appropriate <a href=' '>J2543</a>indicator. But the latest version of OBD2 connector and has the ability to identify the problem. This makes the the mechanic job easier and<a href=''>GM Tech 2</a> low maintenance costs of employers - CR5
2014-08-20, 21:26:18
anonymous from United States  
2015-02-01, 01:13:32
anonymous from Venezuela  
Great article but it didn't have ev-egthinyrI didn't find the kitchen sink!
2015-02-01, 01:13:32
anonymous from Venezuela  
Great article but it didn't have ev-egthinyrI didn't find the kitchen sink!
2017-08-21, 01:15:19
Kimberly from Taiwan  
Hello! I realize this is sort of off-topic however I needed to ask.
Does managing a well-established website like yours take a large amount of
work? I am completely new to operating a blog but I do
write in my journal every day. I'd like to start a blog so I will
be able to share my own experience and thoughts online.
Please let me know if you have any kind of recommendations
or tips for brand new aspiring bloggers. Thankyou!



NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: