A plugin for Backbone.js that caches results of Model.fetch and Collection.fetch calls in memory and localStorage. Version 2.0.1, updated as a stable release. It intercepts fetch calls and serves cached responses when options.cache is true, with configurable expiration. Key differentiator: provides 'prefill' option to populate models/collections from cache immediately then update via AJAX, improving perceived performance. Supports AMD and CommonJS. Requires Backbone >=1.0.0 and jQuery (or compatible Deferred implementation).
npm install backbone-fetch-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to install, require the plugin, and use cache option on fetch.
Use require() or dynamic import with default interop.
Clear cache manually with Backbone.fetchCache.clearItem(url) or set expires to a reasonable value.
Wrap usage in try-catch or disable localStorage via Backbone.fetchCache.localCache = false.
Replace prefillExpires with expires: <seconds> in the fetch options.
Include a library like Standalone-Deferred before loading backbone-fetch-cache.
Ensure jQuery is loaded before the plugin. If using Zepto, include a Deferred implementation.
Run 'npm install backbone-fetch-cache' and check that require path is correct.
Add 'require("backbone-fetch-cache")' after Backbone is loaded.