content-length as a META tag?

Discussion in 'HTML' started by relaxedrob@optushome.com.au, Apr 6, 2004.

  1. Guest

    Hi All!

    I have some programming to do where I can make use of the
    content-length header if it is available.

    My question is can we (and should we) include a content-length META
    tag in the HEAD element or can we only insert a content-length header
    through some server language such as ASP/JSP/PHP/Perl etc?

    Thanks for any advice!

    Rob
    :)
    , Apr 6, 2004
    #1
    1. Advertising

  2. brucie Guest

    in post: <news:>
    () said:

    > My question is can we (and should we) include a content-length META
    > tag in the HEAD element


    what would be the point?

    --
    b r u c i e
    brucie, Apr 6, 2004
    #2
    1. Advertising

  3. wrote:

    > My question is can we (and should we) include a content-length META
    > tag in the HEAD element or can we only insert a content-length header
    > through some server language such as ASP/JSP/PHP/Perl etc?


    With dynamically generated pages (ASP/JSP/PHP/Perl/etc) you generally
    don't know the Content-Length in advance.

    With statically served files, most web servers (tested IIS and Apache)
    seem to insert the Content-Length for you.

    This leaves only gateway-type CGI files -- for example, some kind of
    download.cgi script that checks various authorisation variables,
    increments hit counters or whatever before sending the user a file.

    This is pretty easy to do. For example, with Perl:

    print 'Content-Length: ', (-s $file), "\n";'

    Of course, setting a META tag is more difficult as the tag itself
    will change the file size!

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me - http://www.goddamn.co.uk/tobyink/?page=132
    Toby A Inkster, Apr 6, 2004
    #3
  4. Joshua Beall Guest

    "" <> wrote in message
    news:...
    > Hi All!
    >
    > I have some programming to do where I can make use of the
    > content-length header if it is available.
    >
    > My question is can we (and should we) include a content-length META
    > tag in the HEAD element or can we only insert a content-length header
    > through some server language such as ASP/JSP/PHP/Perl etc?


    I do not understand what the purpose of setting the content-length via a
    META tag would be. Why would you do this?

    Anyway,. the point of setting the content length (I assume) is so that the
    browser knows how long the document is going to be. Apache, at least, takes
    care of this automatically for both images and html (both static and
    dynamically rendered, e.g., PHP/ASP/JSP). See for yourself: telnet to port
    80 of an apache server and do a get request. You will notice that right
    before the first line of content is server, the length of the document, in
    hex, is displayed.
    Joshua Beall, Apr 7, 2004
    #4
  5. Joshua Beall Guest

    "Joshua Beall" <> wrote in message
    news:_pYcc.15257$...
    > "" <> wrote in

    message
    > news:...
    > > Hi All!
    > >
    > > I have some programming to do where I can make use of the
    > > content-length header if it is available.
    > >
    > > My question is can we (and should we) include a content-length META
    > > tag in the HEAD element or can we only insert a content-length header
    > > through some server language such as ASP/JSP/PHP/Perl etc?

    >
    > I do not understand what the purpose of setting the content-length via a
    > META tag would be. Why would you do this?
    >
    > Anyway,. the point of setting the content length (I assume) is so that the
    > browser knows how long the document is going to be. Apache, at least,

    takes
    > care of this automatically for both images and html (both static and
    > dynamically rendered, e.g., PHP/ASP/JSP).


    I was wrong: for static HTML pages, it just sends the content-length header.
    It is only for PHP pages that it prepends the output with the length.

    Also, I imagine not many people are running ASP via Apache, and I have not
    actually tested JSP. I spoke out of turn; sorry.
    Joshua Beall, Apr 7, 2004
    #5
  6. Joshua Beall Guest

    "Toby A Inkster" <> wrote in message
    > With dynamically generated pages (ASP/JSP/PHP/Perl/etc) you generally
    > don't know the Content-Length in advance.


    Hmm, perhaps, but it is not hard to if you want to:

    ob_start();

    {generate page}

    $output = ob_get_contents();
    ob_end_clean();
    $length = strlen($output);

    header("Content-length: $length");

    Of course, if you wanted to add a meta tag, you would have to do some other
    shenanigans, since it would change the content length. But I am still not
    sure why you would want a meta tag with the content length.
    Joshua Beall, Apr 7, 2004
    #6
  7. Mark Parnell Guest

    On Wed, 07 Apr 2004 19:20:41 GMT, "Joshua Beall"
    <> declared in alt.html:

    > Also, I imagine not many people are running ASP via Apache


    We are. Causes lots of headaches. :-( I'm going to convert it to PHP
    when I know it well enough.

    --
    Mark Parnell
    http://www.clarkecomputers.com.au
    Mark Parnell, Apr 8, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shruds
    Replies:
    1
    Views:
    709
    John C. Bollinger
    Jan 27, 2006
  2. Nym Pseudo

    META NAME and META HTTP-EQUIV

    Nym Pseudo, Sep 26, 2003, in forum: HTML
    Replies:
    1
    Views:
    521
    =?iso-8859-1?Q?brucie?=
    Sep 26, 2003
  3. TheKeith
    Replies:
    20
    Views:
    106,261
    Chris Morris
    Oct 29, 2003
  4. Rick
    Replies:
    3
    Views:
    521
    bruce barker \(sqlwork.com\)
    May 10, 2006
  5. Duane Johnson

    Meta methods to govern meta data?

    Duane Johnson, Oct 25, 2005, in forum: Ruby
    Replies:
    6
    Views:
    214
    Adam Sanderson
    Oct 28, 2005
Loading...

Share This Page