'use strict';
const fs = require('fs');
const Promise = require('bluebird');
const readFile = Promise.promisify(fs.readFile, { context: fs });
const cache = require('./cache');

module.exports = readTemplate;

function readTemplate(path, callback) {
    const cacheKey = `template.${path}`;
    return cache.get(cacheKey)
        .catch((err) => {
            return readFile(path)
                .then((buf) => buf.toString())
                .then((value) => cache.put(cacheKey, value, { ttl: 0 }));
        })
        .asCallback(callback);
};

'use strict';
const fs = require('fs');
const Promise = require('bluebird');
const readFile = Promise.promisify(fs.readFile, { context: fs });
const cache = require('./cache');

module.exports = readTemplate;

function readTemplate(path, callback) {
    const cacheKey = `template.${path}`;

    if (process.env.NODE_ENV === 'production') {
        return cache.get(cacheKey)
            .catch((err) => {
                return readFile(path)
                    .then((buf) => buf.toString())
                    .then((value) => cache.put(cacheKey, value, { ttl: 0 }));
            })
            .asCallback(callback);
    } else {
        return readFile(path)
            .then((buf) => buf.toString())
            .asCallback(callback);
    }
};

--- 
+++ 
@@ -8,18 +8,11 @@
 
 function readTemplate(path, callback) {
     const cacheKey = `template.${path}`;
-
-    if (process.env.NODE_ENV === 'production') {
-        return cache.get(cacheKey)
-            .catch((err) => {
-                return readFile(path)
-                    .then((buf) => buf.toString())
-                    .then((value) => cache.put(cacheKey, value, { ttl: 0 }));
-            })
-            .asCallback(callback);
-    } else {
-        return readFile(path)
-            .then((buf) => buf.toString())
-            .asCallback(callback);
-    }
+    return cache.get(cacheKey)
+        .catch((err) => {
+            return readFile(path)
+                .then((buf) => buf.toString())
+                .then((value) => cache.put(cacheKey, value, { ttl: 0 }));
+        })
+        .asCallback(callback);
 };
Revert "only cache templates in production"

This reverts commit 4e2bf7d48d60bba8b4d4497786e4db0ab8f81bef.
