DelphiFAQ Home Search:

Programmatically clear Internet Explorer's cache

 

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

Question:

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

Answer:

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;

uses
  WinInet;

{sc-----------------------------------------------------------------------
  Name:       DeleteIECache
  Parameters: -
-----------------------------------------------------------------------sc}
procedure DeleteIECache;
var
  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
  begin
    repeat
      DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName);
      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);

  FindCloseUrlCache(hCacheDir)
end; { DeleteIECache }


begin
  DeleteIECache
end.

Content-type: text/html

Comments:

2006-07-10, 18:35:11
[hidden] from Australia  
rating
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  
rating
To prevent the deletion of cookies too, insert the following if-statement:

repeat
if lpEntryInfo^.CacheEntryType and COOKIE_CACHE_ENTRY = COOKIE_CACHE_ENTRY then
DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName);

The constant COOKIE_CACHE_ENTRY should have the value $00100000.
2012-11-09, 21:12:14
WattJersey@gmail.com from China  
Pasdfmdbfgj1110     4
http://www.custom49..erseys.com     http://www.custom49..rseys.com
http://www.texanslo..-6_24.html     J J Watt Jersey
http://www.my-packe..-7_20.html     James Jones Jersey
http://www.my-packe..-7_21.html     James Starks Jersey
http://www.official..-6_22.html     Jason Pierre Paul Jersey
http://www.authenti.._c_423_444     Jay Cutler Jersey
http://www.my-packe..-7_26.html     Jermichael Finley Jersey
http://www.baltimor..-6_20.html     Jimmy Smith Jersey
http://www.baltimor..-6_21.html     Joe Flacco Jersey
http://www.my-packe..-7_27.html     John Kuhn Jersey
http://www.texanslo..-6_26.html     Johnathan Joseph Jersey
http://www.authenti.._c_423_445     Johnny Knox Jersey
http://www.my-packe..-7_28.html     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=' http://www.wholesal..ong>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=' http://www.wholesal...com/'> <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=' http://www.perfect-..gt;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-01-05, 01:28:49
anonymous from China  
[url= http://www.perfect-..m/]Monster Beats headphones[/url],sllyjfdibeats [url= http://www.perfect-..eats[/url] and [url= http://www.hotmusic..om/]purple beats by dre[/url] come out,[url= http://www.wonderfu..tml]ibeats earphones[/url] is characterized by its solid housing,balanced sound quality and purest sound producing.,[url= http://www.perfect-..html]Beats Studio Limited Edition[/url] will give you a big surprise!bring the gospel to the vast number of music lovers.[url= http://www.hotmusic..com/]beats studio headphones[/url],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 [url= http://www.wonderfu..tml]ibeats earphones[/url] unlike ordinary in-ear headphones,ibeats earphones are constructed from solid metal housing.With the [url= http://www.hotmusic..html]beats by dre mixr[/url], you can freely enjoy the beautiful music without being disturbed by the outside noise.We supply all kinds of beautiful Monster [url= http://www.wonderfu..com/]Beats by dre[/url], such as ibeats earphones,[url= http://www.wonderfu...html]solo hd bluetooth[/url].With versatile ear segments,extended cords, and various styles of the ear plugs to make a relaxed dressed in experiencesand for you.


Keywords:
2013-02-26, 21:55:58
anonymous  
2013-06-19, 02:03:48
anonymous from United States  
Board diagnostics (OBD) system <a href=' http://www.obd4u.fr..tml'>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=' http://www.obd4u.fr..01101.html '>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=' http://www.obd4u.fr..evice.html '>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=' http://www.obd4u.fr..tml'>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!

 

 

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: