Giter VIP home page Giter VIP logo

ext.ux.proxy.proxycache's Introduction

Ext.ux.proxy.ProxyCache

A Sencha Touch 2 Dual Storage Proxy

A dual storage remote caching proxy. Caches the responses from remote requests in HTML5 Local Storage in order to reduce the number of HTTP requests that need to be made.

Includes extended versions of the default Sencha Touch 2 server proxies (Ajax, JsonP and REST) embellished with the caching functionality.

Installation

Clone the repository or download it using the "Zip" button above.

Place the ux folder in the root of your application (in the same folder as your index.html and app.js). Folder structure should look like the following:

	/
	/app/
	/touch/
	/ux/
	app.js
	index.html

Usage

Within your Model / Store, require the class you wish to use. For example if you wish to use the Ajax proxy with added caching, add the following:

	requires: 'Ext.ux.proxy.AjaxCache'

Then set the type as 'ajaxcache'

	type: 'ajaxcache'

Your Model / Store should look similar to:

	requires: 'Ext.ux.proxy.AjaxCache',
	config:	{
		proxy: {
			type: 'ajaxcache',
			cacheTimeout: 30,
			cacheKey: 'myData',
			url: '/url/to/api/',
			reader: {
				type: 'json'
			}
		}
	}

Note the addititonal options that can be set:

  • cacheTimeout: 30
    • The amount of time until the stored repsonse expires and is cleared automatically from the cache.
    • Required: No
    • Default: 1 hour (value in seconds)
    • This may also be a function. If the function returns false it will invalidate the cache.
  • cacheKey: 'myData'
    • The key to use for localStorage. Allows you to seperate each store into a different local storage item.
    • Required: No
    • Default: 'proxyCache'

Included "type" values are:

	ajaxcache
	restcache
	jsonpcache

For a complete example of this plugin, please see the included "example" folder.

Using in your own Custom Proxy

If you wish to use the caching functionality within your own custom proxy, add the following code to your class (it must extend Ext.data.proxy.Server or a derivative).

	mixins: {
		proxyCache: 'Ext.ux.proxy.ProxyCache'
	}

For more information please take a look at one of the following classes and read the comments:

	Ext.ux.proxy.AjaxCache
	Ext.ux.proxy.JsonPache
	Ext.ux.proxy.RestCache

Credits

Adam Duncan follow me on Twitter

Tommy Maintz

David Collom

Licence

Licenced under the New BSD License

ext.ux.proxy.proxycache's People

Contributors

microadam avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.