How do I set Meteor to not cache anything for a specific page?

假装没事ソ 提交于 2020-01-13 06:32:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!