Playing around with stateless servlets, I find my web cells expiring
unexpectedly quickly. Before going into code, here's what I'm working on
at the moment:
* A new user goes to a registration page and completes the form there
* The inputs are checked. If they're valid, we register the user. (To
simplify the discussion, assume that the inputs are valid.)
* Log the newly created user in by setting a web cell to the ID (a
string?) of the newly created user.
* Use redirect/get, passing the result to an onboarding page ("Thanks
for registering -- Welcome to the club! Here's what you can do here:")
The onboard function takes a request? as input; the newly created user
is not an argument to that function. I'm implementing the concept of
"the current user" using web cells. To get the current user, I use
web-cell-ref. To set the current user, I use web-cell-shadow.
This works, but what I find is that, after about one minute, the web
cell expires. Refreshing the onboarding page (created using
redirect/get), web-cell-ref will soon start returning the initial value
(#f) rather than that string.
In code:
(define (onboard req)
(cond [(string? (web-cell-ref current-user))
(response/xexpr
`(html
(head (title "Welcome!"))
(body
(h1 "You made it")
(p "Welcome to the club")
(h2 ,(web-cell-ref current-user)))))]
[else
(response/xexpr
`(html
(head (title "Huh?"))
(body
(h1 "You logged in before…")
(p "…but now you're GONE."))))]))
starts going into the second branch after about a minute. That is, upon
successfully arriving at the onboard page, I can refresh the page
successfully (without unintentionally registering the user again and
again, in line with my understanding of redirect/get). But if I refresh
the page after about 1 minute, I see "…but now you're GONE".
This is surprising because the memory pressure is surely minimal. This
is all done on my laptop with a single user. Moreover, I'm doing things
here by hand; I"m not flooding the server with a ton of requests, trying
to force the continuation manager to start dropping stuff.
Are my expectations out of line here? Perhaps I'm misunderstanding
something. I was approaching web cells, roughly speaking, as "parameters
for the web", but this kind of behavior makes me think that I'm getting
something wrong (or expecting too much). I'm using the default
continuation manager coming from serve/servlet, which gives me 128 MB.
Given what I'm doing in this case, I find it hard to believe that I'm
exhausting memory, but maybe I am.
--
You received this message because you are subscribed to the Google Groups "Racket
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.