防止POST请求缓存 [英] prevent POST-request from caching
问题描述
当我尝试发出一个jQuery ajax"Type:Post"请求时,我收到一个(从缓存中)找不到404错误.我已经尝试了几种解决方法来解决此问题,但是它没有用.这是我尝试过的解决方法:
When I try to make a jquery ajax "Type:Post" request, I get an 404 not found (from cache) error. I've tried several workarounds to fix this problem but it doesn't worked. This are the workarounds I've tried:
-
在ajax调用中添加头信息: "Cache-Control":私有,无缓存,无存储,必须重新验证", 到期":"0",
Adding header information in ajax call: "Cache-Control" : "private, no-cache, no-store, must-revalidate", "Expires" : "0",
jquery ajax"cache:false"
jquery ajax "cache:false"
添加rnd URL参数,"?nocache=' + new Date().getTime()",
add rnd URL param, "?nocache=' + new Date().getTime()",
试图禁用AppCache(nativ):
tried to disable AppCache (nativ):
"super.appView.getSettings().setAppCacheEnabled(false);"
"super.appView.getSettings().setAppCacheEnabled(false);"
这是我使用开发工具调试Cordova应用程序时从此POST请求获得的响应: http://pl.vc/59s6o
This is the response I get from this POST request when I debug my Cordova App with dev tools: http://pl.vc/59s6o
推荐答案
尝试在$.ajaxSetup
$.ajaxSetup({
type: 'POST',
headers: { "cache-control": "no-cache" }
});
如果您告诉我们更多有关您的情况并包括您的代码,我们可以为您提供更多帮助.
We can help you more if you tell us more about your situation and include your code.
这篇关于防止POST请求缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!