Joseph DeVore's Blog: AJAX
Viewing By Category : AJAX / Main
March 15, 2006
Lately I've been doing a lot with AJAX and have had issues with getting realtime data from the server because IE was caching the data on the first request. In order to prevent caching, I didn't want to switch from GET to POST and I didn't want to append some random query string to each request so I've opted for a more elegant solution IMO, which is to expire the cached page using the If-Modified-Since request header.
See below:
req.open('GET', url, true);
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
req.send(null);
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
req.send(null);
Comments
There are no comments for this entry.

