Total members 9952 | Gratitudes |It is currently Sat Feb 11, 2012 2:49 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 5 posts ] 
Author Question
 Question subject: Solution to AJax Cache problem with Internet Explorer
PostPosted: Wed Aug 22, 2007 9:09 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2103
Location: Earth
Has thanked: 39 time
Have thanks: 57 time

Hi ,
If you are facing a problem with caching in internet explorer and your ajax application .

You can add the following code in your jsp file :

Code:
response.setHeader("Cache-Control", "no-cache");

and in your javascript url
Code:
    var url="UI/RoomDetailsView.jsp?ignoreMe=" + new Date().getTime();


Or in php
Code:
<?php header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");  


have fun, :n_clap:

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Solution to AJax Cache problem with Internet Explorer
PostPosted: Tue Feb 10, 2009 12:34 am 
Offline
Newbie
User avatar

Joined: Tue Feb 10, 2009 12:28 am
Posts: 1
Has thanked: 0 time
Have thanks: 0 time
hi! is this code working? where in particular can i apply the javascript url and the response.setHeader("Cache-Control", "no-cache")?

thank you.. this is my ajax code by the way, maybe you can help me out here where to put the code since i am still a newbie for ajax.

var XMLHttpRequestObject = false;
if (window.XMLHttpRequest)

{
XMLHttpRequestObject = new XMLHttpRequest();
}

else if (window.ActiveXObject)
{
XMLHttpRequestObject = new
ActiveXObject("Microsoft.XMLHTTP");
}

function getData(dataSource, divID)
{
if(XMLHttpRequestObject) {

var obj = document.getElementById(divID);

XMLHttpRequestObject.open("GET", dataSource, true);

XMLHttpRequestObject.onreadystatechange = function()
{
if (XMLHttpRequestObject.readyState == 4 &&
XMLHttpRequestObject.status == 200) {

obj.innerHTML = XMLHttpRequestObject.responseText;
}
}

XMLHttpRequestObject.send(null);
}
}


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Solution to AJax Cache problem with Internet Explorer
PostPosted: Wed Mar 03, 2010 11:54 am 
Offline
Newbie
User avatar

Joined: Wed Mar 03, 2010 11:47 am
Posts: 1
Has thanked: 0 time
Have thanks: 1 time
hi,

some of the code mentioned above is for the server script that recieves the ajax. Unfortunately its the server that gives the headers, so where ever you url in ajx is pointing to you have to place those headers.

response.setHeader(..... i think is for jsp scripts (on the recieving server)
and header("..... i for php scripts (on the recieving server).

having a look at your code, you should probably have a look at using jQuery javascript framework. Its as 100% cross browser support as your going to get.

if you use jquery the code is as simple as:
$.getJSON('http://some.place.com',{
var1:'this is var',
var2:'this is var2'
},myCallbackFuncion);

and it will work where ever ANY browser supports ajax.

hope this helps



For this message the author coombesy has received gratitude : msi_333
TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Solution to AJax Cache problem with Internet Explorer
PostPosted: Wed Mar 10, 2010 3:35 pm 
Offline
Newbie
User avatar

Joined: Wed Mar 10, 2010 1:51 pm
Posts: 1
Has thanked: 0 time
Have thanks: 0 time
Can you show a little example, please?


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Solution to AJax Cache problem with Internet Explorer
PostPosted: Sat Nov 06, 2010 2:50 am 
Offline
Newbie
User avatar

Joined: Sat Nov 06, 2010 2:44 am
Posts: 1
Has thanked: 0 time
Have thanks: 0 time
Just wrote a blog on this exact issue only using ExtJS ( http://thecodeabode.blogspot.com/2010/10/cache-busting-ajax-requests-in-ie.html)

aside from forcing the Pragma: nocache header, you can add additional query string params the the requested url. The article gives examples on how to do this using POST params via javascript


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 5 posts ] 
Quick reply


  


 Similar topics
 Topic title   Forum   Author   Comments 
 Sending One lakh character in ajax  AJAX  Anonymous  0
 Ajax Source code to Suggest application with JSP Server side  AJAX  msi_333  5
 problem with JcheckBox method  Java  Anonymous  1
 [Ajax/PHP] Registration - Check for empty textboxs  AJAX  PF2G  0
 client server problem  Java  bablu1790  0

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 2 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team