How to totally prevent HTTP 304 responses in Connect/Express static middleware?

Jacob Marble picture Jacob Marble · Feb 1, 2013 · Viewed 25.1k times · Source

At times during development, it would be really nice to prevent HTTP 304 responses (in favor of 200's), and cause the Connect/Express static middleware to read every response from the filesystem, rather than do any caching at all.

I have tried playing with maxAge values of 0 and 1, to no avail:

app.use(express.static(__dirname + '/public', { maxAge: 1 }))

Answer

Mark Selby picture Mark Selby · Oct 3, 2013

I get 200 responses by doing this during development :

var express = require('express');
app = express();
app.use(function(req, res, next) {
  req.headers['if-none-match'] = 'no-match-for-this';
  next();    
});