How can browser caching be utilized to reduce load times when including headers and menus on a webpage with PHP?
Browser caching can be utilized to reduce load times by storing static resources such as headers and menus on the user's browser. This way, these resources do not need to be re-downloaded each time the page is visited, reducing load times significantly.
<?php
// Set the cache expiration time to 1 week
$expires = 60 * 60 * 24 * 7;
header('Pragma: public');
header('Cache-Control: max-age=' . $expires);
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
?>