How can HTTP header 307 be used to prevent browser caching of redirection in PHP?
To prevent browser caching of redirection in PHP using HTTP header 307, we can set the cache-control header to no-cache and the expires header to 0. This will ensure that the browser always fetches the latest version of the redirected page without caching it.
<?php
header("HTTP/1.1 307 Temporary Redirect");
header("Cache-Control: no-cache, no-store, must-revalidate");
header("Expires: 0");
header("Location: https://example.com/newpage.php");
exit;
?>
Keywords
Related Questions
- How can PHP developers ensure data integrity when retrieving the value of a specific column in a database?
- What is the significance of the s modifier in a regular expression pattern when matching characters in PHP?
- How can PHP session management be optimized to handle multiple user accounts efficiently?