-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Vue-resource can cancel the cache as Ajax do #190
Comments
I was having the same issue in IE, I fixed this on the server side by adding a Header on requests that were submitted by AJAX. vue-resource already adds a I am using Express, so this was fairly simple since there's already a req.xhr value that checks for the above header. I added the following middleware to the start of my app: app.use(function(req, res, next){
// check for AJAX request and turn off caching
if(req.xhr) res.set('Expires', '-1')
// continue
next()
}) |
you can set http request header
|
I'm doing it like this but I need to make it safe // http request/response interceptors
Vue.http.interceptors.push({
request: function (request) {
// todo(jake): do this properly, don't just blindly append ?..
request.url += "?" + new Date().getTime();
return request;
},
response: function (response) {
return response;
}
}); |
@libertyAlone I tried with |
@superlogical Thanks for the solution |
New solution Vue.http.interceptors.push((request, next) => {
request.url += (request.url.indexOf('?') > 0 ? '&' : '?') + `cb=${new Date().getTime()}`
next()
}) |
Hi folks, |
Christ! Internet explorer must get on board or die |
I use vue-resource for data requests, but found that the second request the same data source will appear the cache data, not the latest data, I would like to ask how to cancel the vue-resource cache settings
ajax cancle cache setting (cache:false)
$.ajax({
type: data_method,
url: data_url,
data:data_string,
dataType: 'json',
cache:false,
success: function(data){
console.log(data)
}
},
The text was updated successfully, but these errors were encountered: