我需要将 X-Frame、Cache-control、Pragma 等响应 header 直接添加到 html 代码中,可能是在 html 元素中使用属性?
它用于通过 href 链接直接来自目录的帮助页面。
有什么方法可以向这些 html 添加标题?
最佳答案
您可以使用 meta
来复制其中的一些。通常不是理想的解决方案,但请查看 meta
标记的 http-equiv
属性。我相信其中很多已在较新的浏览器中弃用。
示例:
<meta http-equiv="Cache-control" content="no-cache"/>
<meta http-equiv="X-Frame-Options" content="sameorigin"/>
<meta http-equiv="pragma" content="no-cache"/>
关于html - 能否直接在html页面中添加http响应头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36159391/