[AOLSERVER] How can I dynamically serve .js .css and images?

2 views
Skip to first unread message

J. Greg Davidson

unread,
Nov 17, 2007, 5:37:27 PM11/17/07
to AOLS...@listserv.aol.com
What is the best way to serve script (*.js and *.css)
and image (*.png and *.svg) files which are stored in
a database?

I am successfully using ns_register_proc to catch and
dynamically serve html page requests.

I would also like to dynamically serve the script and
image files that are embedded in those same html files.

I've tried, for example:
ns_register_proc GET /Images/*.png serve_image
and
ns_register_proc GET /*.png serve_image
to catch requests for my .png files, but my procedure
serve_image does not get called.

What am I missing?

Thanks,

Greg Davidson


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

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

Tom Jackson

unread,
Nov 17, 2007, 6:14:47 PM11/17/07
to AOLS...@listserv.aol.com
Do you get any error messages?

One thing you might need to do is to use an exact proc name ::serve_image.

You should also put an ns_log statement in that proc so that you know it is
being called, or not, maybe print out the url:

ns_register_proc GET /*.png ::server_image png

proc ::server_image {type} {

ns_log Notice "serving image type $type with url [ns_conn url]"

...
}

tom jackson

Bas Scheffers

unread,
Nov 17, 2007, 6:54:33 PM11/17/07
to AOLS...@listserv.aol.com
If you are serving these verbatim from the database with no other
processing, I think you should consider caching them in the file
system for much better performance.

You can do this by creating a 404 handler that checks if the requested
file could be got from the database. If it can, it writes it to the
pageroot and returns it. The next time someone requests it, AOLserver
will serve it straight from the file system.

If you upload a new version of the file to the database, that proc
should then simply delete the existing file from the pageroot.

Here's an example:

http://panoptic.com/wiki/aolserver/AOLserver_Cookbook#Fast_caching_of_generated_pages

Regards,
Bas.

Scott Goodwin

unread,
Nov 29, 2007, 4:04:54 PM11/29/07
to AOLS...@listserv.aol.com
Anyone know where I might find the old ArsDigita AOLserver CVS
repositories? Preferably a later one with all the log history intact.
Reply directly to me.

thanks,

/s.

Reply all
Reply to author
Forward
0 new messages