问题
I am working on a project where I am using Meteor as an implementation. There are set of pages that are being cached and there's no concern.
However, there is one page in the project that I am trying to set for no-cache. How do I achieve that?
EDITED:
Based on chosen accepted answer; I achieved the desired result with this wrapping code:
if (Meteor.isServer) {
Meteor.startup(function () {
WebApp.rawConnectHandlers.use(function (req, res, next) {
res.setHeader('cache-control', 'no-cache');
res.setHeader('expires', '0');
res.setHeader('Content-Type', 'text/html');
res.setHeader('charset', 'utf-8');
next();
});
});
}
回答1:
You can use WebApp to configure cache headers:
//Server code
WebApp.rawConnectHandlers.use('/noCachePagePath', function(req, res, next) {
res.setHeader('cache-control', 'no-cache');
next();
});
来源:https://stackoverflow.com/questions/29260643/how-do-i-set-meteor-to-not-cache-anything-for-a-specific-page