faqts : Computers : Internet : Web Servers : Apache

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

12 of 15 people (80%) answered Yes
Recently 7 of 10 people (70%) answered Yes


Anyone figure out how to broadcast an alert to all users before you shutdown Apache?

Nov 15th, 2001 18:21
Anthony Boyd, Richard Edwards,

HTTP is stateless.  This means that at any given second, there are NO 
users to alert.  Someone who browses 5 pages on your site over the 
course of 30 minutes is not in contact with the server for all 30 
minutes, and is not able to receive notices.  Instead, the server 
just "sees" a request appear out of nowhere, it serves the page back in 
an instant, and closes the connection.  A few minutes later another 
request appears, is served, and the server doesn't "know" that the 
requests are all from the same person.
You can get around this.  The obvious way: put the notice on your home 
page for an hour (or a day) before the downtime.  Or, try this.  Each 
page on your site has a header, probably the same on each page.  Remove 
the header from each file, and instead link to a single header file 
that all your pages can share.  In SSI, this is just the include 
directive, and in PHP this is just the include() method.  Like this:
<?php include("header.html"); ?>
<p>hi, this is my site, and the header above is one shared file</p>
THEN, you can change that header.html file any time you wish, and it'll 
appear in changed form on all pages that include it.  So you can add 
some red bold text that "site going down in 15 minutes for maintenance" 
or whatever.
If you need to get really, crazy-tricky, you can include a hidden frame 
on all your pages, and set that hidden frame to refresh every few 
seconds.  If you're going to take down the server, just add some 
JavaScript to the file in the hidden frame, like this:
<script language="JavaScript">
alert("site going down for 30 minutes")
And BE SURE that you set the refresh to 30 minutes or an hour or 
whatever, so that the alert doesn't keep appearing.  Then when everyone 
refreshes their hidden frames, up pops the alert while they're reading 
some page on your site.