angular.js-server-ng-cache
v0.2.4
Published
A REST API and template caching for server side rendering with angular.js-server
Downloads
3
Maintainers
Readme
#Angular.js-server
This package is a plugin for angular.js-server (https://github.com/a-lucas/angular.js-server).
It allows you to re-play REST calls (API & templates) as soon as the client loads the cached HTML.
This considerably speeds up the AngularJS initial website page load time.
#Workflow
- The browser vist the url
http://domain:port/url
- Your node sever with
angular.js-server
receives the request , and pre-render the HTML. - If the server detects the presence of
angular.js-server-cache
, it will store all the template and ajax calls made during prerender inside the HTML - The Browser receives the generated HTML response
server-cache
module will check if any caching data is available, and will load & use them to render the web app in the client.- Once the Angular app is fully loaded, the caching strategy will be set to
serverCacheConfig.defaultCache
value (Default - false)
#Usage:
bower install angular.js-server-cache
or
npm install angular.js-server-ng-cache
Then include the file:
dist/angular.js-server-ng-cache.min.js
into your HTML, and include the module server-cache
angular.module('yourApp', [ your dependencies..., 'server-cache']);
#defaultcache option
By default, $http caching
is disabled once the application has been rendered in the client.
You can enable it :
angular.module('yourApp', [ your dependencies..., 'server-cache']);
angular.module('server-cache').constant('serverCacheConfig', {defaultConfig: true});
A new cacheFactoryProvider
This file is a modified version of the original AngularJS 1.5 cacheFactoryProvider, and adds several methods to the cache factory.
No code change, just new methods.
##$cacheFactoryProvider.export (cacheId)
Export the secified cache into JSON
##$cacheFactoryProvider.exportAll()
Exports all the caches
##$cacheFactoryProvider.importAll(cacheData)
Import the data exported trough the method exportAll
##$cacheFactoryProvider.import(cacheId)
Specifically import a cache
##$cacheFactoryProvider.info(cacheId)
Get info about a cache
##$cacheFactoryProvider.infoAll()
Get info about all caches