using filemtime on an absolute URL?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Erica

    #1

    using filemtime on an absolute URL?

    Hey,

    I need a function to obtain the "last modified" timestamp from a file.
    filemtime works perfectly well when I am working with a file on my
    server. However, sometimes I need to pass it a full URL from a
    different domain. Is there a way of doing this? I can't get it to
    work...

    Thanks!!
    --Erica
  • Daniel Tryba

    #2
    Re: using filemtime on an absolute URL?

    Erica <erica@technody ke.com> wrote:[color=blue]
    > I need a function to obtain the "last modified" timestamp from a file.
    > filemtime works perfectly well when I am working with a file on my
    > server. However, sometimes I need to pass it a full URL from a
    > different domain. Is there a way of doing this? I can't get it to
    > work...[/color]

    If with URL you mean a http request, you could write a function to do a
    HEAD request for that URL and scan the returning http headers for a
    Last-Modified header (which is optional). There might be other usefull
    headers like Expires, depending on your needs.

    --

    Daniel Tryba

    Comment

    • Chung Leong

      #3
      Re: using filemtime on an absolute URL?

      "Erica" <erica@technody ke.com> wrote in message
      news:346a55df.0 408171551.293d2 f4e@posting.goo gle.com...[color=blue]
      > Hey,
      >
      > I need a function to obtain the "last modified" timestamp from a file.
      > filemtime works perfectly well when I am working with a file on my
      > server. However, sometimes I need to pass it a full URL from a
      > different domain. Is there a way of doing this? I can't get it to
      > work...
      >
      > Thanks!!
      > --Erica[/color]

      You need to open the URL first with fopen(), then call
      stream_get_meta _data() to retrieve its meta data. The 'Last-Modified' header
      is what you need. Example:

      $f = fopen("http://www.google.com/images/logo_sm.gif", "rb");
      print_r(stream_ get_meta_data($ f));
      fclose($f);

      (Yup, the Google logo hasn't changed in a while)


      Comment

      Working...