Can we add http response headers directly into html pages

Viewed 18285

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?

3 Answers

You can add something like this, if php execution is enabled on your web server:

<?php
http_response_code(your_response_code)
?>
rest-of-your-html-code

This will execute a php script that will set the response code.

Related