Re: [AOLSERVER] code for 404 pattern (aka static cache)

2007-10-01 Thread Jeff Rogers

John Buckman wrote:
Bas Scheffers was kind to share his 404-pattern code with me (ie, a 
custom 404 handler to enable static caching of frequently requested 
files), which I used to write my own.


It's not rocket science, but since I asked the question, I thought I'd 
share my code, in case anyone else finds it helpful.


I've taken the liberty of adding this to the wiki, on the "Cookbook" 
page: http://panoptic.com/wiki/aolserver/AOLserver_Cookbook


-J


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.


Re: [AOLSERVER] code for 404 pattern (aka static cache)

2007-09-30 Thread John Buckman

On Sep 29, 2007, at 11:00 PM, Jeff Rogers wrote:


John Buckman wrote:
Bas Scheffers was kind to share his 404-pattern code with me (ie,  
a custom 404 handler to enable static caching of frequently  
requested files), which I used to write my own.
It's not rocket science, but since I asked the question, I thought  
I'd share my code, in case anyone else finds it helpful.


I've taken the liberty of adding this to the wiki, on the  
"Cookbook" page: http://panoptic.com/wiki/aolserver/AOLserver_Cookbook


Thanks for reminding us of this wiki page.  I'll endeavor to put my  
"bits" in there in the future.


-john


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.


[AOLSERVER] code for 404 pattern (aka static cache)

2007-09-29 Thread John Buckman
Bas Scheffers was kind to share his 404-pattern code with me (ie, a  
custom 404 handler to enable static caching of frequently requested  
files), which I used to write my own.


It's not rocket science, but since I asked the question, I thought  
I'd share my code, in case anyone else finds it helpful.


-john

from config.tcl:
ns_section "ns/server/$server1/redirects"
ns_param   404   /404.adp

$ cat 404.adp
<% handle_404 %>


proc handle_404 {} {
set myurl [myurl]
set parts [split $myurl /]
set root [lindex $parts 1]

if {$root == "photo"} {
return [404_photo $parts]
} else {
ns_returnredirect "[myhost]/"
return
}

}

proc 404_photo {parts} {

set userid [file rootname [lindex $parts 2]]
set d [user_photo_data $userid]
if {$d == ""} {
set fn "/b/photo/unknown.jpg"
} else {
set fn "/b/photo/${userid}.jpg"
write_binary_file $fn $d
}
ns_returnfile 200 "image/jpeg" $fn
}

proc myurl {} {
return [lindex [split [ns_conn request]] 1] 
}

proc photo_cache_dirty {userid} {
set fn "/b/photo/${userid}.jpg"
file delete $fn
}


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.