what is http header?
when a request is sent with http, it gives information about the document that comes before the document. You can decide whether to download the document by looking at the date when the document was changed in the direction.
how to add header with nginx?
this is very simple you need edit config file, find location block. for example you want to add all xml files no cache.
location ~* \.(?:xml)$ {
expires -1;
add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
}
how to add header with php?
as a scenario, we want to add a page 404 not found error.
404 Not found error
404 Not found error
<?php
header("HTTP/1.0 404 Not Found");
?>
301 moved permanently
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: /im-going.php");
exit();
?>
custom header
<?php
header('CustomHeaderName: CustomHeaderValue');
?>