#1
  1. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    6
    Rep Power
    0
    I want to use Last-Modified in a php script, but
    it doesn't seem to work somehow.

    i use the following code where $FileDate is a formated date like:
    Sun, 06 Nov 1994 08:49:37 GMT (RFC 822, updated by RFC 1123)

    if($HTTP_IF_MODIFIED_SINCE==$FileDate)
    {
    header("Status: 404 Not Modified");
    die();
    }

    header("Last-modified: ".$FileDate);
    header("Content-type: ".$FileType);
    print $FileData;

    somehow the server doesn't send the header, or the browser
    doesn't sent the If-Modified-Since header. I know for a fact that
    $HTTP_IF_MODIFIED_SINCE is the right variable to compare with.

    I use apache under linux (and mysql), am i forgetting something
    or do i have to set something in my conf file ?

    ------------------
    Greetings lewi
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Newark, DE, USA
    Posts
    39
    Rep Power
    15
    First, 304 is the response code for "Not Modified." 404 is "Not Found." If you send a 404, this signifies a client error, and the request is finished. If you send a 304, you're telling the client that something else is going to happen to finish the request, like a redirect. So you have to send another header (a Location: header) just to finish the request.

    Second, how are you setting $FileDate? And what string do you get if you echo your $HTTP_IF_MODIFIED_SINCE variable? This variable isn't defined in my environment. Can you post a link to someplace that has information about this variable? I can't find ANY references on it.

    ------------------
    ~Chris
  4. #3
  5. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    6
    Rep Power
    0
    304, whoeps my mistake, but that was no
    problem. And after 304, your page can die because the
    browser will use the cashed version of the file/page.

    $FileDate and $FileDate are set by mysql query (and are
    set right, tested it)
    $HTTP_IF_MODIFIED_SINCE i found on some random php output
    on a site.. don't know any more where, and will only be
    available if a succesfull Last-Modified header was sent
    to the browser.
    But some how there it goes wrong..

    just in case here is the query

    $SQL = "SELECT FileData,FileType,DATE_FORMAT(FileDate,'%a,";
    $SQL.= "%d %b %Y %H:%i:%s GMT') FROM FileFiles WHERE FileName='".$file."' AND MapID=".$MapID;
    $connection->Query($SQL);
    if(!(list($FileData,$FileType,$FileDate)=$connection->GetNext()))
    { die("File [".$file."] does not exist");}


    and a filedate printed is:
    "Mon, 16 Oct 2000 20:45:48 GMT"
    And:
    "Last-Modified: Mon, 16 Oct 2000 20:45:48 GMT"
    this should be valid header..isn't it ?

    ------------------
    Greetings lewi

    [This message has been edited by Lewi (edited October 23, 2000).]
  6. #4
  7. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    6
    Rep Power
    0
    still walking with the same question...

    getting a headache etc

    ------------------
    Greetings lewi
  8. #5
  9. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    6
    Rep Power
    0
    I think i found the solution,
    the session object ads automaticly
    cache headers
    there are three modes:
    public,private,no-cache.. and they
    all add headers.. which offcourse SUCKS
    (in my case at least)

    so i added a new mode named userdefined in the source code, which doesn't send any stupid header.

    And this is working for now


    ------------------
    Greetings lewi

Similar Threads

  1. Monitor change in modified image's timestamp
    By christinewang in forum Perl Programming
    Replies: 8
    Last Post: February 16th, 2011, 02:22 PM
  2. Replies: 4
    Last Post: August 5th, 2003, 06:18 PM
  3. last modified
    By MasterChief in forum PHP Development
    Replies: 3
    Last Post: July 9th, 2003, 07:25 PM
  4. Getting the last modified row in mysql db
    By Sauhnik in forum PHP Development
    Replies: 5
    Last Post: May 6th, 2003, 05:43 PM
  5. File last modified
    By butcher in forum PHP Development
    Replies: 3
    Last Post: January 18th, 2002, 04:51 AM

IMN logo majestic logo threadwatch logo seochat tools logo