I wish to make an etag that suits what Apache produces. So how exactly does apache create it's etags?

Apache uses the conventional format of inode-filesize-mtime. The only real caveat for this would be that the mtime should be epoch some time and padded with zeros so it's 16 numbers. This is how to get it done in PHP:

$fs = stat($file);
header("Etag: ".sprintf('"%x-%x-%s"', $fs['ino'], $fs['size'],base_convert(str_pad($fs['mtime'],16,"0"),10,16)));

If you are dynamically producing your page though, this most likely will not seem sensible. If you are in PHP, you are able to select the inode and quality from the primary script, however the modify time will not let you know in case your data has transformed. Unless of course you've got a good caching process or simply generate static pages, etags aren't useful. If you have a great caching process, the inode and quality are most likely irrelevant.

Edit: For those who have no idea what etags are - they are just said to be something that changes once the content has transformed, for caching reasons. The browser will get the etag on the internet server, compares it towards the etag because of its cached copy after which brings the entire page when the etag has transformed.

One factor to keep in mind about Apache's Etags is they don't play well in groupings simply because they include inode information that can—and most likely will—vary between machines within the same cluster.

the solution above (from Chris) is effective, but could be simplified utilizing an implicit cast within the sprintf:

sprintf('"%x-%x-%x"', $s['ino'], $s['size'], str_pad($s['mtime'], 16, "0"));

The recommended %016x does not work since the padding is used following the conversion to hex, instead of before.