etag??
Moderator: General Moderators
etag??
been looking at etags, for conditional http get
any suggestions?
any suggestions?
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: etag??
Suggestions for what?
Re: etag??
dealing with the ability to tell a search bot, no change etc
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: etag??
Suggestions for how to use an ETag? Well, you should be familiar with the specifications for ETag, If-Match, and If-None-Match, and entity tags in general.
Generate the ETag for a resource, before executing the rest of the request, and decide what to do from there: a matching If-Match means to continue else 412 (and stop), while a matching If-None-Match means 412 else to continue. Make sure to send the ETag regardless.
Can you try writing, like, at least two or three sentences of what you want? Throwing a handful of words in a post doesn't do a whole lot.
Generate the ETag for a resource, before executing the rest of the request, and decide what to do from there: a matching If-Match means to continue else 412 (and stop), while a matching If-None-Match means 412 else to continue. Make sure to send the ETag regardless.
Can you try writing, like, at least two or three sentences of what you want? Throwing a handful of words in a post doesn't do a whole lot.
Re: etag??
I was wondering, would a md5 hash do the job to notice if a given page is modified to deal with it
http://www.microsoft.com/search/Tools/default.aspx
http://www.microsoft.com/search/Tools/default.aspx
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: etag??
Sure, hash of the filename + modification time should cover most the bases. It depends on your needs: is the modification time alone enough to identify a version of a page?
Re: etag??
It would but I am not so sure how to massage that
I know how to display the modification date
so how can i massage this into something the bot would like
I know how to display the modification date
Code: Select all
<?php echo "Last modified: " . date ("F d, Y (H:i:s)", getlastmod()); ?>
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: etag??
Hash it.
Code: Select all
header("ETag: " . md5(date("YmdHis", getlastmod())));Re: etag??
thanks it now recognizes an etag as desired, but now how about the conditional GET, or is that more of a server issue?
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: etag??
It's entirely server-side. If you're sending ETags then the client may send any of those If-*-Match headers I mentioned earlier (including a third one that I didn't list there). Check the links to see what you're supposed to do if you see them.
Re: etag??
the bot check recognizes the etag generated fine, but its still balking at conditional get
so is the bot sending me an etag that i need to check?
so is the bot sending me an etag that i need to check?
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: etag??
Clients don't send ETags. Your server does. They send If-*-Match headers.
For example, if you reply with "ETag: abc123" then their next request may include "If-None-Match: abc123"; if it does match then you respond with a 412 and no content. Or maybe they send "If-Match: abc123", and you give a 412 if it doesn't match.
For example, if you reply with "ETag: abc123" then their next request may include "If-None-Match: abc123"; if it does match then you respond with a 412 and no content. Or maybe they send "If-Match: abc123", and you give a 412 if it doesn't match.
Re: etag??
maybe something like this?
Code: Select all
function isModified($mtime, $etag) {
return !( (
isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
&&
strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $mtime
) || (
isset($_SERVER['HTTP_IF_NONE_MATCH'])
&&
$_SERVER['HTTP_IF_NONE_MATCH'] == $etag
) ) ;
}
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: etag??
Yes, except you react differently for If-Modified-Since and If-None-Match: for the former you return a 304 Not Modified in case of failure and for the latter you return a 412. So you can't just bundle the two checks together like that.
Re: etag??
given I only want to tell a bot I am modified
isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
so is the bot sending me an etag I need to handle?
isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
so is the bot sending me an etag I need to handle?
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP