スクリプトでいくつかの呼び出しを行っており、キャッシュ制御を処理$.post
するために使用したいと考えています。$.ajaxSetup
function function1()
$.ajaxSetup({
type: 'POST',
headers: { "cache-control": "no-cache", "pragma-cache": "no-cache" }
});
$.post('getLists.php', {user: authUser, token: authToken}, function(data){
$('nav a[class!=btnNewList]').remove();
$.each(data.objects, function(index, element){
$('nav').append('<a href="#" data-list-id="'+element.id+'">'+element.title+'</a>');
});
$('nav').children('a:first-child').next('a').addClass('selected');
getClipsForList($('nav').children('a:first-child').next('a').attr('data-list-id'));
}, 'json');
function function2(){
$.ajaxSetup({
type: 'POST',
headers: { "cache-control": "public", "pragma-cache": "public" }
});
$.post('getClips.php', {user: authUser, token: authToken}, function(data){
spinner.stop();
$.each(data.objects, function(index, element){
if(element.list == '/api/lists/'+id+'/'){
$('#clips ul').append('<li data-url="'+element.url+'">'+truncate(element.title, 100)+'</li>');
}
});
},'json');
}
私はモバイル Web アプリを作成していますが、それが JSON 応答をキャッシュしていることに気付いたので、調査を行って$.ajaxSetup
解決策を見つけました。それはうまく機能しましたが、キャッシュ制御プロパティの設定に関係なく、現在は常にキャッシュしているようです。特定の $.post 呼び出しのみをキャッシュしたいと思います。これを行う方法はありますか?
$.ajax
キャッシュされたデータが必要な関数の代わりに使用し、グローバル プロパティを false に設定しようとしまし$.post
たが、それでもキャッシュされません。