HTML and CSS Reference
$generations = $_GET['generations'];
header('Etag: "' . $generations . '"');
If I ever change the format this script generates, I'll need to adjust the ETags as well. Alternatively, I could use
weak entity tags. By default, entity tags are assumed to be strong, which means that two representations have
the same entity tag if and only if they are byte-per-byte identical. However, if you put W/ in front of the quoted
string, it becomes a weak entity tag. Documents that share a weak entity tag mean the same thing, but may
not be byte-per-byte identical. For instance, if I converted a JPEG to a GIF, I could keep a weak entity tag the
same, but not a strong one. A weak entity tag looks like this:
There are few limits on what you can put in an ETag. It must be ASCII text. It cannot contain any control
characters, including carriage returns, line feeds, and tabs. It must be double-quoted. Otherwise, use any
format that works for you.
The second step for the web application to support ETags is to recognize when someone sends it an ETag and
sending a 204 response instead. Clients can send multiple entity tags in a header separated by commas to
indicate that they have multiple representations prestored. For example:
If-None-Match: "6548d4-30a9e-c7f4e5c0", "756ed4-44a5e-1cf56c09"
In this case, the server should send a 304 Not Modified response if any of the supplied entity tags match the
current state of the resource along with the ETag that matches.