UNPKG

1.52 kBMarkdownView Raw
1# coffee-cache
2
3Caches the contents of required CoffeeScript files so that they are not
4recompiled to help improve startup time.
5
6## What it does
7
8In a Node.js application written in CoffeeScript, every time you start the
9application, all the relevant files must be compiled when they are required. If
10you have a very large application, this process can consume a large portion of
11your startup time. By caching the compiled JavaScript files, only those that
12have been updated must be recompiled, and the rest can be loaded off of the
13disk. In our usage, this has reduced the startup time from 7s to 2s, which means
14a lot when you have to restart your application every time you want to test a
15change.
16
17## How to use
18
191. Add to your package.json dependencies and run `npm install` or run `npm install coffee-cache`.
20
212. In your entry point file, add the following:
22
23 ```coffee
24 require('coffee-cache')
25 ```
26
273. That's it. By default the files are cached in the `./.coffee/` directory. If
28 you want to change this, see below.
29
30## Extra configuration
31
32You can specify the location of the directory to use for the cached files in one
33of two ways:
34
351. Start the process with the `COFFEE_CACHE_DIR` variable set:
36
37 ```sh
38 $ COFFEE_CACHE_DIR=/tmp/coffee-cache coffee app.coffee
39 ```
40
412. Use the `setCacheDir` method on the required module:
42
43 ```coffee
44 require('coffee-cache').setCacheDir('../cached/')
45 ```
46
47Just make sure your process has permission to create the necessary folder or
48files.