Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable browser cache?

I have an ajax function (in jquery) which update the html. It's ok. Now, When I tap enter in the adress bar (to refresh), my html is not updated (old content). Whereas, when I do cmd + R, my html is always ok.

What is the problem ? Why my content shows old content from the adress bar ?

Edit :

I use Chrome et load() in jQuery

like image 986
Steffi Avatar asked Apr 26 '26 22:04

Steffi


1 Answers

If you have problem with caching in the browser itself, you need to set header to prevent caching in your Server Side's Code (e.g. Php, Java, Python .....etc).

But if you want to avoid caching in your Ajax Function use this Code:

 $.ajax({
              url : scriptUrl,
              type : "get", // or 'post'
              cache : false, // This is to avoid Cache in Ajax Requests
              // .........................etc
});

Notice: Give more details on your question to get a sharper answer.

like image 148
Shehabic Avatar answered Apr 28 '26 12:04

Shehabic