Comments (1)
By default, Hoard uses whatever is returned from the result of model.url
as the cache key. So if your URL includes query params, Hoard will include them in your cache key. If this doesn't apply to your model class in question, you can overwrite key generation for the policy associated with your cache control:
var QueryParamStrippingPolicy = Hoard.Policy.extend({
// model, method, and options passed down from sync
// return a string representing the cache-level identity of this request
// This example strips query params
getKey: function (model, method, options) {
return _.result(model, 'url').split('?')[0];
}
});
var queryParamStrippingControl = new Hoard.Control({ policyClass: QueryParamStrippingPolicy });
var MyModel = Backbone.Model.extend({
url: function () {
return '/models/' + this.id + '?timeSubmitted=' + Date.now();
},
// Enable Hoard caching
// The QureyParamStrippingPolicy will remove '?timeSubmitted=...' from the cache key
sync: queryParamStrippingControl.getModelSync()
});
from backbone.hoard.
Related Issues (20)
- Allow for expires: false in the Policy HOT 1
- Hoard.Store should create a metaStore with the provided options
- Race condition in ReadStrategy
- Expose backend-accessing methods on Hoard.Store as an async API HOT 2
- More Docs + Existing docs on gh-pages HOT 3
- Change default store to `{}` HOT 2
- Remove cache expiration HOT 1
- Proxy-wrap Backbone.sync instead of directly delegating HOT 1
- Handle data hash in GET request similar to jQuery HOT 1
- Update to use ES6 HOT 1
- Investigate useful places for lifecycle events HOT 1
- Move entire test suite to karma
- Improve the build process
- Strategy should not modify the options HOT 1
- Pass unmodified options to Hoard.Sync
- Use new Promises instead of Promise.resolve().then
- Find model collection using model urlRoot property HOT 2
- Fix Store/MetaStore inheritance instead of using StoreHelpers
- Provide a default "cache-bypass" strategy HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from backbone.hoard.