Skip to content

Instantly share code, notes, and snippets.

@andybeak
Last active June 16, 2017 15:46
Show Gist options
  • Save andybeak/4f736bb5c3be39fdaa60a0bacc13eb6b to your computer and use it in GitHub Desktop.
Save andybeak/4f736bb5c3be39fdaa60a0bacc13eb6b to your computer and use it in GitHub Desktop.
I set an ETag that is based on a static version number because the only time I would want to process the file is if the version changes.
<?php
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == sha1('version 1.0')) {
header('HTTP/1.1 304 Not Modified');
exit;
}
header('Cache-Control: max-age=604800, public');
header('ETag: ' . sha1('version 1.0') );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment