Sivakatirswami ,

> I can move the source text and templates to the web server and convert my
> local metacard button script to a .mt script and then let the web server
> build the page each time someone hits on it.

I did much the same thing at http://www.navaching.com to serve up new daily
Haiku and proverbs. The page is built just ONCE a day, automatically at the
site. Every time someone hits on the page cgi checks the date (compares it
with a text file) and if it's tomorrow rebuilds, if it's today then just
sends the page.

The trick was (is) two fold:
1) generating a new page
2) and the "Status: 204 No Content" & cr business below. This was the
hardest part until I found 204. Without 204 you'll get an error, as the web
is set up on a call/response basis. What you want to do is send nothing back
and that's what 204 does. So the guts of the script below only kicks in once
a day, otherwise the page is sent. 204 is what made the whole thing
possible.

You can make it work without 204 but the FIRST hit tomorrow (the rebuilding
hit) gets today's page.  If your traffic is heavy and/or you aren't to
concerned about that first soul who shows up tomorrow then you can drop 204.

#!mc
------- update.mt    update html pages
on startup
 -----------------checkdate
  put url "file:seconds.mt" into it
  if the seconds>it then
    put the short date into temp
    convert temp to seconds
    put (temp+86400) into temp  --the daily seconds
    open file "seconds.mt" for write
    write temp to file "seconds.mt" at 0
    close file "seconds.mt"
    -- generate data for new pages
    --update pages You have dummy pages with variables in the html and just
search for and replace with the data generated
    -- send 'Update' page
    put url "file:../update.html" into buffer
    put "Content-Type: text/html" & cr
    put "Content-Length:" && the length of buffer & cr & cr
    put buffer
  else put "Status: 204 No Content" & cr  --a non response
end startup

There is a slightly better explanation in Section 8 of
http://www.navaching.com/pagem.html.

This deal has been running for a couple years without a hitch.

Nelson Zink


Archives: http://www.mail-archive.com/metacard@lists.runrev.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to