我有一个统计跟踪器的web应用程序,与vue.js构建的前端和部署在vercel上。此外,我还使用express.js构建后端,并部署在heroku上。每当我搜索用户统计数据时,它都会缓存结果。如何禁用缓存结果?
前端:
axios.defaults.headers = {
'Cache-Control': 'no-cache',
'Pragma': 'no-cache',
'Expires': '0',
};后端:
app.use(cors(corsOptions));
app.use(nocache()) //npm library
app.set('etag',false)
app.disable('view cache')发布于 2021-03-04 00:13:31
https://stackoverflow.com/questions/39129932/explicitly-disable-caching-for-rest-services[1]以某种方式回答了这个问题。您可以实现一个中间件,将Cache-Control: must-revalidate,no-cache,no-store设置为我们想要禁用缓存的所有标头。
https://stackoverflow.com/questions/66460628
复制相似问题