Skip to content

Instantly share code, notes, and snippets.

@vnnvanhuong
Created August 23, 2020 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vnnvanhuong/72bfb7822d1ff31724b10f385caa164d to your computer and use it in GitHub Desktop.
Save vnnvanhuong/72bfb7822d1ff31724b10f385caa164d to your computer and use it in GitHub Desktop.
'use strict';
const express = require('express');
const PORT = process.env.PORT || 8080;
const app = express();
app.use(express.static('public', {
etag: true,
lastModified: true,
setHeaders: (res, path) => {
if (path.endsWith('.html')) {
res.setHeader('Cache-control', 'no-cache');
}
},
}));
app.listen(PORT, function() {
console.log('Your server is running on port ' + PORT);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment