From 105cb9e67f3083047b408e30f04f0de22ebeb2ca Mon Sep 17 00:00:00 2001 From: Nick Martin Date: Fri, 1 Mar 2013 18:43:20 -0800 Subject: [PATCH] Go back to caching static assets. Reverts change released in 0.5.5. --- app/server/server.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/server/server.js b/app/server/server.js index f58d581955..c6f8640105 100644 --- a/app/server/server.js +++ b/app/server/server.js @@ -180,8 +180,21 @@ var run = function () { var app = connect.createServer(); var static_cacheable_path = path.join(bundle_dir, 'static_cacheable'); if (fs.existsSync(static_cacheable_path)) - app.use(gzippo.staticGzip(static_cacheable_path, {clientMaxAge: 1000 * 60 * 60 * 24 * 365})); - app.use(gzippo.staticGzip(path.join(bundle_dir, 'static'), {clientMaxAge: 0})); + // cacheable files are files that should never change. Typically + // named by their hash (eg meteor bundled js and css files). + // cache them ~forever (1yr) + app.use(gzippo.staticGzip(static_cacheable_path, + {clientMaxAge: 1000 * 60 * 60 * 24 * 365})); + // cache non-cacheable file anyway. This isn't really correct, as + // users can change the files and changes won't propogate + // immediately. However, if we don't cache them, browsers will + // 'flicker' when rerendering images. Eventually we will probably want + // to rewrite URLs of static assets to include a query parameter to + // bust caches. That way we can both get good caching behavior and + // allow users to change assets without delay. + // https://app.asana.com/0/2604819267102/4310170949669 + app.use(gzippo.staticGzip(path.join(bundle_dir, 'static'), + {clientMaxAge: 1000 * 60 * 60 * 24 * 7})); // read bundle config file var info_raw =