Skip to content
RobeeeJay edited this page Aug 23, 2012 · 3 revisions

This module serves static content such as images, css and js files from a specified directory. It uses the Lactate node module for this purpose, which supports memory caching and gzipping automatically.

new fw.StaticFile({ staticDir: "/static", expireTime: "two days", cacheMem: true });

staticDir should point to the root directory which contains your static content. expireTime is the cache time for the content, see the Lactate documentation for more details. cacheMem (enabled by default) is whether files should be cached to reduce disk access.

Simple Example

var stackFull = new fw.Stack();

stackFull.append(new fw.StaticFile({ staticDir: __dirname + "/static" }));

If the request.url is "/images/dog.jpg" and the file "./static/images/dog.jpg" exists, this will send that file to the client. Otherwise it will continue with the next entry in the Stack.