我们可以将http响应标头直接添加到html页面中吗
问题描述:
我需要将响应标头(例如X-Frame,Cache-control,Pragma等)直接添加到html代码中,也许是在html元素中使用属性吗?
I need to add response headers like X-Frame, Cache-control, Pragma etc directly into the html code, may be, using attributes in html elements?
用于直接通过目录链接来自目录的帮助页面.
It is for help pages which are directly coming from a directory via href link.
有什么方法可以向这些html添加标头吗?
Is there any way to add headers to these htmls?
答
您可以使用meta
复制其中一些内容.通常,这不是理想的解决方案,但是请查看meta
标记的http-equiv
属性.我相信其中的许多功能已在较新的浏览器中弃用.
You can use meta
to replicate some of these. Normally not the ideal solution, but look into the http-equiv
attribute of meta
tags. I believe a lot of these have been deprecated in newer browsers.
示例:
<meta http-equiv="Cache-control" content="no-cache"/>
<meta http-equiv="X-Frame-Options" content="sameorigin"/>
<meta http-equiv="pragma" content="no-cache"/>