mercredi 10 juin 2015

Ember-Data subsequent find does not cache but generates XHR

I have an app built using ember-cli 0.2.5 (which is Ember 1.12.0 and Ember-Data 1.0.0-beta.17).

My models' store.find() always generate XHR request to my backend. I would expect subsequent route accesses to use the store's cache.

I have two routes, router.js is:

Router.map(function() { this.route('rules', {path: '/rules'}); this.route('users', {path: '/users'}); });

The routes models are:

Ember.Route.extend({ model: function (params) { return this.store.find('user'); } });

and

Ember.Route.extend({ model: function (params) { return this.store.find('rule'); } });

I am using the RESTAdapter and targeting an apache server which executes a perl cgi. The returned JSON (snippet) is:

{"rules":[{"canAutoUnblock":1,"creator":"spaling","status":null,"autoUnblockDate":"2015-05-30","createTime":"2015-01-19 19:59:56","privComment":"not private","pubComment":"Port scanning the Library","id":12,"ipaddr":"31.7.59.152"},{"canAutoUnblock":0,"creator":"spaling","status":"delete","autoUnblockDate":null,"createTime":"2015-01-19 19:59:56","privComment":"private","pubComment":"public","id":13,"ipaddr":"31.7.59.160"},

formatted ...

{ rules: [ { canAutoUnblock: 1, creator: "spaling", status: null, autoUnblockDate: "2015-05-30", createTime: "2015-01-19 19:59:56", privComment: "not private", pubComment: "Port scanning the Library", id: 12, ipaddr: "31.7.59.152" }, { canAutoUnblock: 0, creator: "spaling", status: "delete", autoUnblockDate: null, createTime: "2015-01-19 19:59:56", privComment: "private", pubComment: "public", id: 13, ipaddr: "31.7.59.160" },

Any advice greatly appreciated.

Barry




Aucun commentaire:

Enregistrer un commentaire