Created
December 18, 2012 11:49
-
-
Save albyr/4327346 to your computer and use it in GitHub Desktop.
Example PHP file for generating ETags for Little Printer publications.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// You need to pick one of the following lines, based on how often your publication will be updated | |
// The value of the 'date' function will then be hashed to produce the ETag | |
// date = date(z); // Generates ETag based on the day of the year, so publication updates daily | |
// date = date(W); // Generates ETag based on the week number, so publication updates on Monday of each week | |
// date = date(F); // Generates ETag based on the month, so your publication updates monthly | |
date = date(c); // Generates ETag based on the current date and time, so your publication updates every second (but will only be polled by BERG Cloud for each user once per day at the scheduled time) | |
// Generates MD5 hash of your given value | |
$md5 = md5($date); | |
// Sets the previously generated hash value as the page's ETag | |
header("ETag: ".$md5); | |
?> | |
<!-- Begin HTML for your publication --> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Really neat 👍