-->

How do I set Meteor to not cache anything for a sp

2020-07-24 06:10发布

问题:

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();
});