Coder Social home page Coder Social logo

jquery-ajax-localstorage-cache's Introduction

About

jquery-ajax-localstorage-cache is a plugin built for jQuery (>1.5.1) and localStorage. It's a fork from the jStorage-dependent original. It provides a client-side cache AJAX responses intended to save bandwith and time.

How to use

Parameters

	$.ajax({
		url          : '/post',
		localCache   : true,        // required to use

		cacheTTL     : 1,           // in hours. Optional
		cacheKey     : 'post',      // optional
		isCacheValid : function(){  // optional
			return true;
		},

		success: function(reply) {
			// i can play with my reply ! 
		}
	});

On your AJAX request you get 4 new parameters :

  • localCache
    • Turn localCache on/off
    • Default: false
  • cacheTTL
    • time in hours the entry should be valid.
    • only for this specific ajax request
    • Default : 5 hours
  • cacheKey
    • CacheKey is the key that will be used to store the response in localStorage. It allow you to delete your cache easily with the localStorage.removeItem() function.
    • Default: URL + TYPE(GET/POST) + DATA
  • isCacheValid
    • This function must return true or false. On false, the cached response is removed.
    • Default: null

Notes

  • You can delete the cache by using localStorage.clear().
  • Note that you can pre-load content with this plugin. You just have do to the same AJAX request without a success callback and the same cacheKey.

License

This project is distributed under Apache 2 License. See LICENSE.txt for more information.

jquery-ajax-localstorage-cache's People

Contributors

basicallydan avatar bshelton229 avatar caleywoods avatar dguzzo avatar iryusa avatar mludv avatar nigelkibodeaux avatar paulirish avatar robink avatar shaqq avatar

Watchers

 avatar  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.