Click here to Skip to main content
11,921,889 members (60,908 online)
Rate this:
Please Sign up or sign in to vote.
See more: Javascript CSS

I have a requirement , I have to clear browsers Javascript and css as I start my web application.

This should be done in Javascript Code. or if you have any better solution then pls let me know.

I dont wnat to clear chache because I am saving ID and Password in that.

Any help is highly appreciated.


Posted 28-Jan-13 3:05am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can't clear browser cache using Javscript

But you can clear the application cache pragmatically.
$('.button').click(function() {
        url: "",
        context: document.body,
        success: function(s,x){
        $('html[manifest=saveappoffline.appcache]').attr('content', '');

or you have to disable the cache control
<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>
or you have to load your files(css/images/script) as following like way
?modified=20130116044521 is a dynamic parameter just like current-time-stamp

Application cache[^]

please check the following link for more caching information[^]
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Clearing browser's JavaScript and css is not a good idea.

Instead make sure that for each time, browser detects the css and JavaScripts as new ones, not the old ones.

For that you can do something like below.
<script src="someJs.js?v=1001" ></script>
<link href="someCss.css?v=2001"></link>
To achieve this automatically, refer the article - Automatic JavaScript, CSS versioning to refresh browser cache[^].

Another solution may be - Cache clear problem after style sheet changes[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 568
1 Dave Kreskowiak 285
2 Sergey Alexandrovich Kryukov 173
3 Richard MacCutchan 155
4 ppolymorphe 135
0 OriginalGriff 7,036
1 KrunalRohit 4,530
2 Sergey Alexandrovich Kryukov 3,286
3 George Jonsson 2,840
4 Suvendu Shekhar Giri 2,216

Advertise | Privacy | Mobile
Web01 | 2.8.151120.1 | Last Updated 28 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100