<p>I want to make an etag that matches what Apache produces.  How does apache create it's etags?</p>

[{'answer_id': 44939, 'author': 'Chris Bartow', 'author_id': 497, 'author_profile': 'https://Stackoverflow.com/users/497', 'pm_score': 5, 'selected': True, 'text': '<p>Apache uses the standard format of inode-filesize-mtime.  The only caveat to this is that the mtime must be epoch time and padded with zeros so it is 16 digits.  Here is how to do it in PHP:</p>\n\n<pre><code>$fs = stat($file);\nheader("Etag: ".sprintf(\'"%x-%x-%s"\', $fs[\'ino\'], $fs[\'size\'],base_convert(str_pad($fs[\'mtime\'],16,"0"),10,16)));\n</code></pre>\n'}, {'answer_id': 44952, 'author': 'Neall', 'author_id': 619, 'author_profile': 'https://Stackoverflow.com/users/619', 'pm_score': 1, 'selected': False, 'text': '<p>If you\'re dynamically generating your page though, this probably won\'t make sense. If you\'re in PHP, you can pick the inode and file size of the main script, but the modify time won\'t tell you if your data has changed. Unless you have a good caching process or just generate static pages, etags aren\'t helpful. If you do have a good caching process, the inode and file size are probably irrelevant.</p>\n\n<p>Edit: For people who don\'t know what <a href="http://en.wikipedia.org/wiki/HTTP_ETag" rel="nofollow noreferrer">etag</a>s are - they\'re just supposed to be a value that changes when the content has changed, for caching purposes. The browser gets the etag from the web server, compares it to the etag for its cached copy and then fetches the whole page if the etag has changed.</p>\n'}, {'answer_id': 45095, 'author': 'Hank Gay', 'author_id': 4203, 'author_profile': 'https://Stackoverflow.com/users/4203', 'pm_score': 2, 'selected': False, 'text': "<p>One thing to remember about Apache's Etags is that they don't play well in clusters because they include inode information that can—and probably will—vary between machines in the same cluster.</p>\n"}, {'answer_id': 6590786, 'author': 'PWolanin', 'author_id': 826248, 'author_profile': 'https://Stackoverflow.com/users/826248', 'pm_score': 1, 'selected': False, 'text': '<p>the answer above (from Chris) works well, but can be simplified using an implicit cast in the sprintf:</p>\n\n<pre><code>sprintf(\'"%x-%x-%x"\', $s[\'ino\'], $s[\'size\'], str_pad($s[\'mtime\'], 16, "0"));\n</code></pre>\n\n<p>The suggested <code>%016x</code> doesn\'t work because the padding is applied after the conversion to hex, rather than before.</p>\n'}]
['https://Stackoverflow.com/questions/44937', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/497/']