Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jokinkuang/pagecache.js
a cache that only live in a page, just like cookie cache but it is page cache
https://github.com/jokinkuang/pagecache.js
Last synced: 5 days ago
JSON representation
a cache that only live in a page, just like cookie cache but it is page cache
- Host: GitHub
- URL: https://github.com/jokinkuang/pagecache.js
- Owner: jokinkuang
- Created: 2016-08-25T02:55:17.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-05T07:49:06.000Z (about 8 years ago)
- Last Synced: 2024-11-12T07:04:04.972Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pagecache.js
a cache that only live in a page, just like cookie cache but it is page cache## Dependence
no dependece## Why Need It
sometimes we got an API that returns like this:
`
{
comments: "1",
likes: "2",
reposts: "3"
}
`
usually we do this by one request:
```javascript
jQuery.getJson("the API url", function(json){
// handle the comments
// handle the likes
// handle the reposts
});
```
but with pagecache we can do following by one reqeust too:
```javascript
$PC("the API url", function(json){
// handle the comments
});
$PC("the API url", function(json){
// handle the likes
});
$PC("the API url", function(json){
// handle the reposts
});
```
they are separate and independent
## Usage
### json
``` javascript
$PC("http://jokinkuang.github.io/Postfile", function(json, state, xmlhttp_obj){
// handle the json object
}, function(state, xmlhttp_obj) {
// handle the error
});
```### jsonp
``` javascript
$PC("http://jokinkuang.github.io/Postfile?callback=?", function(json, state, jsonp_obj){
// handle the json object
}, function(state, jsonp_obj){
// handle the error
});
```
> just add a `callback=?` into the request URL### open the log
set `$PC.Log.level=2` before function call
> DEBUG: 2
> INFO: 1
> ERROR: 0### $PC function
$PC("url", successFunctionCall, errorFunctionCall);
`json`
successFunctionCall(json, state, xmlhttp_obj);
errorFunctionCall(state, xmlhttp_obj);
`jsonp`
successFunctionCall(json, state, jsonp_obj);
errorFunctionCall(state, jsonp_obj);### `NOTE` have not support POST
## License
Under The [MIT](https://tldrlegal.com/license/mit-license) License