向响应添加 Cache-Control
标头
以下示例函数将 Cache-Control
HTTP 标头添加到响应中。该标头使用 max-age
指令告诉 Web 浏览器将响应最多缓存两年(63072000 秒)。有关更多信息,请参阅 MDN Web Docs 网站上的 Cache-Control
这是查看器响应函数。
function handler(event) { var response = event.response; var headers = response.headers; // Set the cache-control header headers['cache-control'] = {value: 'public, max-age=63072000'}; // Return response to viewers return response; }