AngularJS

Introduction

AngularJS is an awesome framework designed to run Web Applications. SEO is usually not a requireemnt for web applications, and AngularJS is bad at SEO for the reason that the client doesnt see anything when the client receives the requests from the server.

In order to have the prerenderer working, I need to make sure that all the initial templates are loaded, and all the REST api calls are completed.
In short, I have to make sure that the Angular application is in IDLE state. And Angular1 doesn't trigger (yet) this idle state event.

$http caching

When rendering the HTML on the server, every templateRequest and REST call are cached and injected into the client before the angular app runs.
Then all the requests are instantly replayed, increasing considerably the client page load.

URL filtering

You can decide which URLs will be pre-rendered, and uses either of the two strategies include or exclude by providing an array of Regexes to match URL against.

Logging

Not implemented (yet)

How to use

install

npm install angular.js-server

Config object

var path = require('path');

module.exports = {

name: "myApp",

log: path.resolve( __dirname + './../logs'),

server: {

domain: 'server.example',

port: 3000,

timeout: 15000

},

cache: {

type: 'file', // possible values: none, file

fileDir: path.resolve( __dirname + './../cache'),

cacheMaxAge: [{

regex: /.*/,

maxAge: 10

}],

cacheAlways: [],

cacheNever: [],

cacheTimestamp: []

},

render: {

strategy: 'include', // possible values: include, exclude

rules: [

/.*/, //pre-render it all !

]

}

};

server

timeout is the number in seconds before the server consider the request timed out. If it is reached, the current (and possibly incomplete) rendered HTML will be sent to the client.

cache

This is a very basic cache engine that takes 4 types of caches

cacheMaxAge is an array of objects of type:

{

regex: regular Expression

maxAge: integer (Seconds)

}

cacheAlways and cache Never are array of js objects

{

regex: regular Expression

}

cacheTimestamp:
TODO To be implemented

name:

This is the name of the angularJS application present in the ng-app tag.