Skip to content

Instantly share code, notes, and snippets.

@seantrane
Last active April 21, 2018 13:16
Show Gist options
  • Save seantrane/3794302 to your computer and use it in GitHub Desktop.
Save seantrane/3794302 to your computer and use it in GitHub Desktop.
PHP: Headers
/* Time-Scales */
$aTimeScale = array(
'year' => 31536000,
'month' => 2628000,
'week' => 604800,
'day' => 86400,
'hour' => 3600,
'minute' => 60
);
/* Expires */
$sExpire = 'Expires: '.gmdate("D, d M Y H:i:s", time() + $aTimeScale['hour']).' GMT';
/* Cache */
header($sExpire);
/* No-Cache */
//header('Cache-Control: no-cache, must-revalidate');
/* JSON */
header('Content-Type: application/json; charset: UTF-8');
/* XML */
//header('Content-Type: text/xml; charset: UTF-8');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment