Node.js / Express Caching

I'm new to Node.js / Express, but I think I'm slowly pondering this. I added this code, which from what I can say seems pretty standard:

app.configure('production', function() { var oneYear = 31557600000; app.use(express.static(__dirname + '/public', { maxAge: oneYear })); app.use(express.errorHandler()); }); 

A look in Chrome Chrome reveals that yes, all caching. Hooray! But when I run Chrome checks on my site (and, as I noticed, on other sites with Node), Chrome says that the site is not caching anything. What could cause this mismatch?

+7
source share
1 answer
 var express = require('express'); var app = express.createServer(); var oneYear = 31557600000; app.use(express.static(__dirname + '/public', { maxAge: oneYear })); app.use(express.errorHandler()); app.get('/', function(req, res){ res.send('hello world'); }); app.listen(3000); 

Executing the above code and going to the test.html page, which is located in the / public directory and has a test image, gives me the following response headers, and Chrome Audit works fine on my PC (Chrome 17.0.963.83, Linux, Node 0.6.13, Express last). You should check if it is really in production mode.

 Accept-Ranges:bytes Cache-Control:public, max-age=31557600 Connection:keep-alive Date:Fri, 23 Mar 2012 22:52:24 GMT ETag:"120877-1278958150000" Last-Modified:Mon, 12 Jul 2010 18:09:10 GMT X-Powered-By:Express 
+11
source

All Articles