Today, doing an ajax function started to use the data submitted by the way has been found to get the data submitted are the same, the data returned is also not a long time to refresh, and I know that this is a problem ajax cache, later on the Internet compiled some ajax caching problem solving, Here to share with you. Solution: 1
Today, doing an ajax function started to use the data submitted by the way has been found to get the data submitted are the same, the data returned is also not a long time to refresh, and I know that this is a problem ajax cache, later on the Internet compiled some ajax caching problem solving, Here to share with you.
Solution: 1, a random number added to the link request, if using the jQuery, disposed directly: $ .ajaxSetup ({cache: false}); 2, POST change the type, and a random parameter setting data: 'a = b' (the parameters must be set, otherwise still be cache) 3, talk generated different number, to use a random number Math.random (); or or timestamp + new Date (); example
Later on the Internet to find a lot of AJAX GET request will be sum up Cache Solution 1, plus the service side header ( "the Cache-Control: Cache-NO, MUST-revalidate"); A poly Xiao Bian Tip You: ajax caching problem on our above methods have a simple test is valid according to their own people prefer it, of course, sometimes we need caching feature sometimes we may not need to be set according to the actual situation. |