Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Clear Browser Cache in Javascript?

Status
Not open for further replies.

s0crates9

Technical User
Jun 18, 2005
70
US
Hi everyone.

I've got a unique question. Is there a command or way to clear the browser cache onclick? I would like to apply a button on a test page that can clear browser cache from IE, Firefox, Netscape, etc.

Any assistance in this would be awesome. I suspect there is a way since in Javascript you can add bookmarks and other browser functions...

Thanks!

Web site design, internet marketing, SEO and business solutions company.
 
You can probably do this in IE using the FileSystemObject to delete all the files in a specified folder, but that would assume that you know where every user who visits your site has their cache folder.

Other than that, I doubt this can be done.

Dan




[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
s0crates9, is your company IE only?
You could use ActiveX to clear out the folders and use system variables to determine the path to the temporary internet files folder for the current logged on user. The ActiveX will cause warnings to the user though.



Paranoid? ME?? Who wants to know????
 
You do not need to create the ActiveX controls only to use ones included with IE. The FileSystemObject BillyRayPreachersSon mentioned above is one such object and exactly the one you need for accessing the file system of the local PC. It gets invoked with a command like:
var fso = new ActiveXObject('Scripting.FileSystemObject');

Most of your examples for using FileSystemObject will be in VBScript but you can find some searching for Javascript and more searching for JScript.
Then you need to search for info on Windows environment variables. I do not know if there is one specifically for the Temporary Internet Files folder but something like %APPDATA% get's you close in Win 2000 system. From there you have to back up one folder then go into Local Settings/Temporary Internet Files. There may be other more direct variables and what you use may depend on what version OS you are dealing with.



Paranoid? ME?? Who wants to know????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top