user5494886
user5494886

Reputation:

If PHP sends two headers, which will be effective?

If I have two headers like:

header("Cache-Control: public");
header("Cache-Control: private");

Which will be effective (first or last)?

Upvotes: 0

Views: 65

Answers (1)

Sebastian Brosch
Sebastian Brosch

Reputation: 43594

On this script the second header() will be used:

<?php
    header('Location: http://google.de');
    header('Location: http://stackoverflow.com');

On your script the second header() will be used:

<?php
    header("Cache-Control: public");
    header("Cache-Control: private");

If a header was defined multiple times, the last one will be used!

Upvotes: 1

Related Questions