Answer the question
In order to leave comments, you need to log in
304 Not modified. How to cache ajax requests?
There is a backend on Yii2. The controller checks before responding:
$behaviors['httpCache']=[
'class' => 'yii\filters\HttpCache',
'only' => ['index','test'],
'lastModified' => function ($action, $params) {
$q = new \yii\db\Query();
return $q->from('user')->max('updated_at');
},
];
$scope.linkto = function() {
$http.get("http://yii-application/frontend/web/users?access-token=1234567", {crossDomain:true, xhrFields: {withCredentials:true}})
.success( function (data) {
console.log(data);
$scope.news = data;
})
.error(function(jqXHR, textStatus, errorThrown) {
console.log("error " + textStatus);
})
}
$scope.linkto();
<div ng-controller="TabController">
<button ng-click="linkto()">clickme</button>
</div>
Answer the question
In order to leave comments, you need to log in
cache: false put in $http.get? You can add a random number to the request every time, ETag and use.
https://docs.angularjs.org/api/ng/service/$http
If you set the default cache to false then only requests that specify their own custom cache object will be cached. From there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question