Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Javascript CSS
Hi,
how to delete css, javascript file from browser cache from codebehind?
Posted 15-Jan-13 23:36pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

you can't clear the browser cache form the code behind. code behind files are executed on the server side. (Assuming your project is ASP.NET). And also, as far as I know, you can't clear browser cache using client side script such as javscript etc..
 
you can clear the application cache pragmatically.
$('.button').click(function() {
    $.ajax({
        url: "",
        context: document.body,
        success: function(s,x){
 
        $('html[manifest=saveappoffline.appcache]').attr('content', '');
 
            $(this).html(s);
    }
});
});
 
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
/style.css?modified=20130116044521
 
?modified=20130116044521 is a dynamic parameter just like current-time-stamp
 
Application cache
http://www.html5rocks.com/en/tutorials/appcache/beginner/[^]
 
please check the following link for more caching information
http://www.mnot.net/cache_docs/[^]
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
You can't...

what you can do you can set expire of cache : Link[^]
Or No cache.
 

But you can't remove client temp file from code behind.
  Permalink  
Comments
ashuslove at 26-Nov-14 6:44am
   
I have ample number of the jquery in all the pages if i am going to change this manually it will take a month. If you can help me to resolve in all without coding to each page
Suvabrata Roy at 29-Nov-14 14:46pm
   
Yes you can...
Option 1 : Write a HttpModule which will add the above code in each request.
Option 2 : Write a base class a which will derive system.web.page and derived it in all other your CS page but be careful you should put your code in page unload because all developer will write some code in page load if you override it may react differently.

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

  Print Answers RSS
0 OriginalGriff 410
1 Jochen Arndt 200
2 Richard MacCutchan 135
3 DamithSL 105
4 PIEBALDconsult 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,032
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,220


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 16 Jan 2013
Copyright © CodeProject, 1999-2014
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