how to clear the cache data when using ajax?

前端 未结 6 2160
星月不相逢
星月不相逢 2021-01-25 17:44

I am using Ajax to retrieve the data from server as below based on some ID to perform auto suggest function. however when i submit the form and update the database, the auto sug

6条回答
  •  悲哀的现实
    2021-01-25 18:00

    you could use http headers to prevent the response from being cached:

    Cache-Control: no-cache
    Expires: Mon, 24 Oct 2005 16:13:22 GMT
    

    Another option is to add another parameter to the url that varies everytime (for example the current time in millis), that way for the browser you ask another url and the cache won't be used.

提交回复
热议问题