Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > content-length as a META tag?

Reply
Thread Tools

content-length as a META tag?

 
 
relaxedrob@optushome.com.au
Guest
Posts: n/a
 
      04-06-2004
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

 
Reply With Quote
 
 
 
 
brucie
Guest
Posts: n/a
 
      04-06-2004
in post: <news:. com>
() 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
 
Reply With Quote
 
 
 
 
Toby A Inkster
Guest
Posts: n/a
 
      04-06-2004
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

 
Reply With Quote
 
Joshua Beall
Guest
Posts: n/a
 
      04-07-2004
"" <> wrote in message
news: om...
> 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.


 
Reply With Quote
 
Joshua Beall
Guest
Posts: n/a
 
      04-07-2004

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

message
> news: om...
> > 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.


 
Reply With Quote
 
Joshua Beall
Guest
Posts: n/a
 
      04-07-2004
"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.


 
Reply With Quote
 
Mark Parnell
Guest
Posts: n/a
 
      04-07-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Meta-Meta-Programming, revisited Erik Veenstra Ruby 21 07-25-2006 10:26 PM
Meta-Meta-Programming Erik Veenstra Ruby 29 02-08-2006 08:22 PM
Meta methods to govern meta data? Duane Johnson Ruby 6 10-28-2005 03:57 AM
META NAME and META HTTP-EQUIV Nym Pseudo HTML 1 09-26-2003 09:13 AM
How to write my own meta tags in any new aspx file created in visual studio Mathew George ASP .Net 1 07-01-2003 02:27 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57