im unable to correctly configure Etag on user browser. When a user clicks on one of my external links, I would like to set the article identifier in my Etag (I also use cookies, but id would like to experiment with Etag specifically to check its reliability).
When the same user returns to my site in a few hours / days, I would like to read the Etag value and use it for others.
I can set Etag to the initial click, but when the user returns the Etag value, it disappeared. I guess it expired or something else. Here is the code I tried:
<? $time = 1280951171; $lastmod = gmdate('D, d MYH:i:s \G\M\T', $time); $etag = '123'; $ifmod = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $lastmod : null; $iftag = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? $_SERVER['HTTP_IF_NONE_MATCH'] == $etag : null; if (($ifmod || $iftag) && ($ifmod !== false && $iftag !== false)) { header('HTTP/1.0 304 Not Modified'); } else { header("Last-Modified: $lastmod"); header("ETag: $etag"); } print_r($_SERVER); ?>
Peter John
source share