Comments (5)
Conditional application of Express middleware is a problem that's plagued Helmet and Express in general. Would something like this work for you?
app.get('/some-route',
function (req, res, next) {
if (res.get('cache-control')) {
nocache()(null, res, next);
} else {
next();
},
function (req, res) {
res.send('this is the response');
}
);
from nocache.
Your solution is perfectly valid, I was just hoping to make it less clunky.
from nocache.
I don't want to add something to Helmet (conditional middleware) that I feel should really be added to Express. (I've tried a few times to write a generalized conditional middleware package but have been unable to find something much less clunky than my solution above.)
Is it okay if I close this issue?
from nocache.
👍
from nocache.
Feel free to open a new issue if you run into anything else!
from nocache.
Related Issues (17)
- Deprecate the `noEtag` option
- Move linting into `pretest`
- Remove `noEtag` option
- Add missing test for Surrogate-Control header
- Clearer documentation on order of .use() HOT 7
- Convert module to TypeScript
- Just `no-store` HOT 4
- Cache-Control should include private HOT 7
- Documentation link not working HOT 1
- Upgrading nocache to 3.0.2 breaks compilation for a Typescript/commonjs project HOT 2
- Removal of Pragma Header HOT 5
- Cache-Control: private may enable caching in the browser HOT 3
- Cache-Control: should we set max-age=0? HOT 3
- Why removing the private? HOT 3
- Better description of headers in readme
- ETag is not removed HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nocache.