Forum Moderators: coopster

Message Too Old, No Replies

question about touch()

         

willybfriendly

10:15 pm on Feb 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am wanting to change the last modified times on some dynamic pages (for SE food). It looked like touch() would accomplish this, but I noted the following comment on the PHP site:

"To spare you ppl couple of hours of valuable time, you can only TOUCH a file that you own! Usually PHP is *nobody* "

So my question is, will an automated script using touch($file) effectively change the last modified, and if not, what is a better way to accomplish this.

(I have several frequently changing pages that just don't get crawled as frequently as I would like, and am thinking that the bots see them as static, unchanging pages as i am currently set up.)

WBF

mincklerstraat

8:03 am on Feb 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



First off, if they're not ole static html files hanging on an apache server, the spiders won't know what the last modified date is no matter how you change it. This info is sent out via the http headers, and php 'takes care' of these for you, meaning basically it sends out headers only with the content type, and without any relevant caching info (since the file modification time is used for the purposes of caching). If you use php, you don't send any last-modifed date at all unless you write something to send this header out with header().

If they are static html files, apache sends out the last-modified information. The commenter is correct, at the very least, the files have to be set so your webserver has write permissions for them. This would go, though, for any process you'd want to use PHP for. The file permissions are there to protect you.

willybfriendly

9:00 pm on Feb 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a "static" page with a .php extension. That is, this page is its own file sitting in its directory under its own name. As such, calling it will generate http headers unique to it.

On that page is a little script that loads frequently updated information.

Now of course, the displaying of new info generated by script does not change the http headers. That is where touch() would come in.

Currently the page shows a last modified date a couple of years old, though the content is freshly generated today.

My thought is to include touch() at the beginning of the content generation script. Something like

$file = $_SERVER['DOCUMENT_ROOT']."page.php";
touch($file);
$content = get_contents();
echo $content;

Now, I probably could have written and tested something in less time that it has taken me to write this, so I guess I will go try to do that :)

WBF