Can we add http response headers directly into html pages

Pramod picture Pramod · Mar 22, 2016 · Viewed 12k times · Source

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.

Is there any way to add headers to these htmls?

Answer

Ross Presser picture Ross Presser · Mar 22, 2016

In short: no, you cannot. HTML files are the body of an HTTP response; the headers must come from the server. Anything you could embed in the HTML file would just become part of the body.