我们可以将http响应标头直接添加到html页面中吗 [英] Can we add http response headers directly into html pages

查看:65
本文介绍了我们可以将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"/>

这篇关于我们可以将http响应标头直接添加到html页面中吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆