【发布时间】:2018-06-19 11:25:46
【问题描述】:
我需要在getInitialProps 方法中使用动态值设置Cache-Control 标头。我尝试了以下。
if(context.res){
context.res.setHeader('Cache-Control','My-Cache-Control');
context.res.setHeader('My-Header','My-Value');
}
但看起来 NextJs 在发送响应之前覆盖了标头值。以下是浏览器响应标头中的cache-control标头值。
Cache-Control: no-store, must-revalidate
My-Header: My-Value
如果有任何遗漏,请告诉我。
【问题讨论】:
标签: javascript reactjs nextjs