Click here to Skip to main content
13,553,688 members
Rate this:
Please Sign up or sign in to vote.
See more:

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 2: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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01-2016 | 2.8.180515.1 | Last Updated 28 Jan 2013
Copyright © CodeProject, 1999-2018
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