PHPackages                             sqginfo/formcache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. sqginfo/formcache

ActiveLibrary[Caching](/categories/caching)

sqginfo/formcache
=================

A simple jQuery form cache plugin.

0.0.4(2y ago)03MITJavaScript

Since Feb 5Pushed 2y ago1 watchersCompare

[ Source](https://github.com/sqginfo/formcache)[ Packagist](https://packagist.org/packages/sqginfo/formcache)[ Docs](https://github.com/sqginfo/formcache)[ RSS](/packages/sqginfo-formcache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

[Form Cache](https://github.com/sqginfo/formcache)
==================================================

[](#form-cache)

A simple jQuery form cache plugin.

Getting started
===============

[](#getting-started)

Quick start
-----------

[](#quick-start)

Three quick start options are available:

- [Download the latest release](https://github.com/sqginfo/formcache/archive/master.zip).
- Clone the repository: `git clone https://github.com/sqginfo/formcache.git`.
- Install with [NPM](http://npmjs.org): `npm install formcache`.

Installation
------------

[](#installation)

Include files:

```

```

Usage
-----

[](#usage)

### Initializes with `data-toggle="formcache"` attribute

[](#initializes-with-data-toggleformcache-attribute)

```

```

### Initializes with `$.fn.formcache` method

[](#initializes-with-fnformcache-method)

```

```

```
$('#form').formcache()
```

Options
-------

[](#options)

#### key

[](#key)

- Type: `String` | `Number`
- Default: `''`

A special identification for the form cache, must be different to other forms in the same page.

By default, the form's index in the document will be used as the `key`.

#### local

[](#local)

- Type: `Boolean`
- Default: `true`

Store cache in localStorage.

#### session

[](#session)

- Type: `Boolean`
- Default: `true`

Store cache in sessionStorage.

#### autoStore

[](#autostore)

- Type: `Boolean`
- Default: `true`

Update and store the cache automatically when a form control changed or before page unload.

#### maxAge

[](#maxage)

- Type: `Number`
- Default: `undefined`

set the stored time (in seconds) of the caches, just like the `max-age` for `cookie`.

By default, the session caches will be cleared when the browser closes, and the local caches will be stored all the time.

**Notes**:

- session caches still will be cleared when the browser closes.
- local caches still will be cleared when the browser caches clears.

#### controls

[](#controls)

- Type: `Array`
- Default:

```
[
  'select',
  'textarea',
  'input'
]
```

A jQuery selectors array. Defines the form controls which need to be cached.

**Note:** All file inputs will be ignored always by default.

Methods
-------

[](#methods)

#### getCache(\[index\])

[](#getcacheindex)

ParamsTypeDefaultDescriptionindex`Number``0`Cache indexGet the default cache object or a special one.

**Examples:**

```
$().formcache('getCache')
$().formcache('getCache', 1)

```

#### getCaches()

[](#getcaches)

Get all cache objects.

**Examples:**

```
$().formcache('getCaches')

```

#### setCache(\[index, \]data)

[](#setcacheindex-data)

ParamsTypeDefaultDescriptionindex`Number``0`Cache indexdata`Object`Cache itemOverride the default cache object or add a new one.

**Examples:**

```
$().formcache('setCache', {})
$().formcache('setCache', 1, {})

```

#### setCaches(data)

[](#setcachesdata)

ParamsTypeDescriptiondata`Array`Cache itemsOverride the old caches with new caches.

**Examples:**

```
$().formcache('setCaches', [{}])
$().formcache('setCaches', [{}, {}])

```

#### removeCache(\[index\])

[](#removecacheindex)

ParamsTypeDefaultDescriptionindex`Number``0`Cache indexRemove the default cache object or a special one.

**Examples:**

```
$().formcache('removeCache')
$().formcache('removeCache', 1)

```

#### removeCaches()

[](#removecaches)

Remove all cache objects.

**Examples:**

```
$().formcache('removeCaches')

```

#### outputCache(\[index\])

[](#outputcacheindex)

ParamsTypeDefaultDescriptionindex`Number``0`Cache indexOutput the default cache object or a special one to the form.

The outputed cache object will be updated automatically when any form control changed.

**Examples:**

```
$().formcache('outputCache')
$().formcache('outputCache', 1)

```

#### serialize()

[](#serialize)

Serialize the form and return a cache object.

**Examples:**

```
var cache = $('form').formcache('serialize');

$('form').formcache('setCache', cache);
$('form').formcache('setCaches', [cache, cache]);

```

#### store()

[](#store)

Store all caches to sessionStorage or localStorage.

The plugin will do this automatically when a form control changed, or the window unloaded.

#### clear()

[](#clear)

Clear all caches.

#### destroy()

[](#destroy)

Destroy the formcache instance, but keep the caches.

If you want to remove all caches, you can call `clear` method first and then call this method.

Browser Support
---------------

[](#browser-support)

- Chrome 31+
- Firefox 31+
- Internet Explorer 8+
- Opera 26+
- Safari 5.1+
- iOS Safari 7.1+
- Android Browser 4.1+
- Chrome for Android 39+

As a jQuery plugin, you can reference to the [jQuery Browser Support](http://jquery.com/browser-support/).

[License](https://github.com/sqginfo/formcache/blob/master/LICENSE.md)
----------------------------------------------------------------------

[](#license)

Released under the [MIT](http://opensource.org/licenses/mit-license.html) license.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

832d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8b4e5b28bdf4efaa84a4ebfc6b46e16c32eca4dbbb88ca762bb64375fd0c75eb?d=identicon)[sqginfo](/maintainers/sqginfo)

---

Top Contributors

[![amandita3581](https://avatars.githubusercontent.com/u/55669500?v=4)](https://github.com/amandita3581 "amandita3581 (12 commits)")

---

Tags

webjavascriptcachedevelopmentformfront-end

### Embed Badge

![Health badge](/badges/sqginfo-formcache/health.svg)

```
[![Health](https://phpackages.com/badges/sqginfo-formcache/health.svg)](https://phpackages.com/packages/sqginfo-formcache)
```

###  Alternatives

[psr/simple-cache

Common interfaces for simple caching

8.1k727.3M2.1k](/packages/psr-simple-cache)[psr/cache

Common interface for caching libraries

5.2k686.9M1.3k](/packages/psr-cache)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[beste/in-memory-cache

A PSR-6 In-Memory cache that can be used as a fallback implementation and/or in tests.

2512.2M6](/packages/beste-in-memory-cache)[anahkiasen/flatten

A package for the Illuminate framework that flattens pages to plain HTML

33313.0k](/packages/anahkiasen-flatten)[rtcamp/nginx-helper

Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also provides cloudflare edge cache purging with Cache-Tags.

23817.0k1](/packages/rtcamp-nginx-helper)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
