views:

100

answers:

1
$.ajax({
  type: 'GET',      
  url: "string.txt",
  cache: false,
  success: function(str){
    alert("Data is: "+ str);
  }
});

In this example, string.txt is sent to the cache (\Temporary Internet Files) How do I ensure that the file is not sent. I do not want copy to be sent.
Only a read from the server. Am I missing an option?

I set cache to false but that does not block it from being sent to client. For example, ajax POST does not send a local copy.....

Here is some background info to what i am trying to do, but with jQuery.

I am curious as to why the standard ajax post seems to have the desired functionality I am looking for and am unable to do that with jQuery?

Thanks

+2  A: 

Or set a no cache header server-side.

Jakub Hampl
@Jakub Hampl: Can I do that just for this specific file?
Tommy
@Tommy: Of course. HTTP cache-control headers are part of each individual respomse, not some global server-wide setting.
Wyzard
@Wyzard: thanks, obviously, I do not know much about server side functionality. I am curious as to why the standard ajax post http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp seems to have the desired functionality I am looking for and am unable to do that with jQuery?
Tommy
I set general the HTTP header "Cache-Control", "max-age=0" in all server responses. It say client that the client must every time verify your client side cache. If server set also "ETag" in the HTTP header with a value like a hash from data in the responses, then the "ETag" from the client side cache will be always automatically send to server. Server can verify clients "ETag" with the current server data and answer with response contains empty body and "304 Not Modified" instead of "200 OK" in response. Then $.ajax response will be get data from the local client cache.
Oleg