Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 }))
like image 570
Jacob Marble Avatar asked Feb 01 '13 07:02

Jacob Marble


2 Answers

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();    
});
like image 51
Mark Selby Avatar answered Sep 18 '22 11:09

Mark Selby


app.disable('etag');

preventing 'etag' in response may help

like image 30
Mohan R Avatar answered Sep 17 '22 11:09

Mohan R