?
Solved

disable caching while using ajax script

Posted on 2010-09-08
2
Medium Priority
?
379 Views
Last Modified: 2012-05-10
I am running an ajax script that calls a php script that runs a query and returns the values to a specific div.

The problem I am running into is that when I refresh the page the webpage wants to use the cashe because it will load faster, I want it to run the ajax script so it will run the query and show me the updated information...

I guess I need to disable to cashe...Thats what I am not sure how to do..
0
Comment
Question by:brad0525
2 Comments
 
LVL 5

Accepted Solution

by:
sscotti earned 2000 total points
ID: 33628293
Not a pro at that, but as far as the php script is concerned you can usually use headers to force no cache:

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

See http://php.net/manual/en/function.header.php.

You can also see:

http://www.sitepoint.com/forums/showthread.php?t=335651
0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 33628419
make a new url everytime
var myTime = myDate.getTime();
var url=’http://localhost/call_to_ajax.php?rand=’+myTime;
http.open(‘GET’, url);

this will make sure that request goes to server every time
check this also
http://hungred.com/how-to/tutorial-stop-caching-jquery-javascript/
http://starcoder.wordpress.com/2006/12/05/deep-tech-fusion/
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question