Ralph Sluiters fed this fish to the penguins on Tuesday 06 January 2004
02:07 am:
[color=blue]
> The caching can not be decoupled, because the cgi-script gets an
> folder ID gets only data from this "folder". So if I decouple die
> processes, I don't know which folders to cache and I can not cache all
> folders, because the routine is to slow. So I must get the actual
> folder from cgi and then cache this one as long as the uses is in this
> folder and pulls data every 2 Minutes and cache another folder, if
> the uses changes his folder.
>[/color]
I've been having some difficulty following this thread but...
Isn't this what Cookies are for? Obtaining some sort of user ID/state
that can be passed into the processing to allow for continuing from a
previous connection?
HTTP is normally stateless. The client requests a page, the page
contents are obtained (either a static page, or some CGI-style
computation generates the immediate page data), the page is returned,
and the connection ends. If the page needs to be updated, that is a
completely separate transaction.
Cookies are used to link these separate transactions into one "whole";
the first time the client requests the page, a cookie is generated. On
subsequent requests (updates) the (now) existing cookie is sent back to
the server to identify the user and allow for selecting the proper
continuation state.
[color=blue]
>
> At the position *** the rest of the script must be uncoupled, so that
> the client can proceed with the actual data, but the new data
> generation for the next time ist stored in a file.
>[/color]
I've not coded CGI stuff (don't have access to a server that permits
user CGI) but my rough view of this task would be:
CGI******
if no cookie
generate a cookie for this user
endif
pass (received or generated) cookie to background process
wait for return-data from background process (if a new cookie, this
will take time to compute, otherwise the background process should
already have computed it)
return web-page with cookie and data
Background********
loop
scan "cache" list for expired cookies (unused threads)
terminate related process thread (process thread should clean up disk
files used)
clean up (delete) cookie from "cache" list
get request (and cookie) from CGI
if the cookie is not in the "cache" list
create new processing thread
endif
Use cookie data to identify (existing) processing thread and read next
data batch from it (queue.queue perhaps, one queue per cookie).
Return data (processing thread continues to compute next update)
endloop
You probably want to include, in "Background" a bit of logic to track
"last request time" and terminate processing threads if no client has
asked for an update in some period of time. The Cookies should also
have expiration times associated so that reconnecting after a period of
time will force a new cookie.
As for the folder? If the user physically navigates to other folders,
that can be passed to the background process and used to update the
threads (or create a new thread, if you assume the cookie identifies a
folder).
Caching would be semi-automatic here. The processing threads could be
folder specific, and when the thread is terminated (on lack of update
requests... let's see, you expect 2-minute update period, allow for a
slow net, say you terminate a process after 5 minutes of disuse...) you
can clean up the disk space (folder) that process was using. The cookie
expiration time would be updated on each update.
The master web page should have whatever HTML tags force a timed
reload to do a new request every 2 minutes.
--[color=blue]
> ================================================== ============ <
>
wlfraed@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
>
wulfraed@dm.net | Bestiaria Support Staff <
> ================================================== ============ <
> Bestiaria Home Page:
http://www.beastie.dm.net/ <
> Home Page:
http://www.dm.net/~wulfraed/ <[/color]