Last active
August 29, 2016 16:54
-
-
Save zenithtekla/8e22f34dad8bb9d53cf2bdbc478b0617 to your computer and use it in GitHub Desktop.
Express-Header
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[express/connect.static] Set ‘Last-Modified’ to now to avoid 304 Not Modified | |
OCTOBER 12, 2011 KONSTANTIN VLASENKOLEAVE A COMMENT | |
Why do I need this? The right answer is: I don’t need that trick! | |
The example below is just to show how to use routes to intercept requests to a static file. | |
Put router before static. | |
app.use(app.router); | |
app.use(express.static(__dirname + '/static')); | |
Add '/*' handler (don’t forget to call next()) | |
app.get('/*', function(req, res, next){ | |
res.setHeader('Last-Modified', (new Date()).toUTCString()); | |
next(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment