prevent POST-request from caching

一曲冷凌霜 提交于 2019-12-25 13:29:46

问题


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:

  1. Adding header information in ajax call: "Cache-Control" : "private, no-cache, no-store, must-revalidate", "Expires" : "0",

  2. jquery ajax "cache:false"

  3. add rnd URL param, "?nocache=' + new Date().getTime()",

  4. tried to disable AppCache (nativ):

"super.appView.getSettings().setAppCacheEnabled(false);"

This is the response I get from this POST request when I debug my Cordova App with dev tools: http://pl.vc/59s6o


回答1:


Try setting your headers in the $.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.



来源:https://stackoverflow.com/questions/23392351/prevent-post-request-from-caching

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!