Networking, Programming and Graphics Tutorials

Prevent AJAX scripts from caching [1/2]

Type: Code Networking, Programming and Graphics Tutorials
Prevent AJAX scripts from caching
Level: Intermediate Networking, Programming and Graphics Tutorials Networking, Programming and Graphics Tutorials 
Prevent AJAX scripts from caching
Date: 2008-Jul-06
Prevent AJAX scripts from caching
Visited: 2348 times
Prevent AJAX scripts from caching
Rating: Prevent AJAX scripts from caching
Prevent AJAX scripts from caching
Author: Ivory Morhuld

AJAX is modern new technology which gives you an advanced way to improve the quality, speed and interactivity of internet applications. But the applications which intensively using AJAX, have one problem. To request data they make a URL post to server side script. This URL is cached by the client browser and even the server will serve new data, old data will be received by the browser.

var url='ajax.php?data='+str;
To solve this problem we will use some small fix. We have to add something unique to the URL, which will be with different value each time when the request will be sended. To do this we will use some value from current time.

To get the current time we will create an variable named date and will assign Date() object to this variable. Next using getTime() property on date variable will get the current time in new variable named timestamp.

var date = new Date();
var timestamp = date.getTime();
Networking, Programming and Graphics Tutorials - Prevent AJAX scripts from caching [1/2] - Networking, Programming and Graphics Tutorials

Need a specific tutorial? Do not hesitate and submit a request!
Related Tags: Prevent AJAX scripts from caching  ajax prevent caching  prevent caching ajax  prevent ajax caching  prevent ajax from caching  prevent ajax from caching  prevent caching of ajax  prevent IE caching with ajax  ajax prevent caching  ajax call + prevent caching  prevent ajax request caching  ajax tutorial prevent caching  prevent caching ajax requests  prevent browsers from caching php ajax  ajax prevent page caching  ajax request prevent caching  prevent browser caching ajax  php prevent "from caching"  prevent caching php  prevent php from caching