[Catalyst] query once per session?
nothingmuch at woobling.org
Thu Apr 26 23:04:06 GMT 2007
On Thu, Apr 26, 2007 at 14:35:09 -0700, Michael Higgins wrote:
> I'm wondering how I can get a query (that becomes a drop-down list for a
> form field) set to execute only once and return the data from the client
> side, or at least from memory, until the session ends.
> I've set something up to filter results based on selection from a form, but
> getting the list each and every time is too lengthy a process for a table
> only updated once a day.
> I've tried using Plugin::Catalyst::Cache, but the docs leave me clueless.
I've invested quite a bit of time writing and auditing the docs with
others, so I don't know if I can wholeheartedly apologize for that
;-) Please come to #catalyst and we'll see if we can give you a
small shove in the right direction (ping nothingmuch).
Using a serverside cache will let you have finer control over the
time to live (for example just till the next scheduled update of the
table), and will also allow you to share results between users
easily. It should work well in conjunction with the other options, too.
can store JSON in a cookie from the server, or embed it in the JS
and have the JS load it. Either way it should be a simple eval()
once you read the cookie value. This will probably waste the least
bandwidth of the three options, but will be the most PITA to write.
Sharing results between users will be tricker here, though.
Yet another option is to simply add caching headers to a JSON feed:
and then set that up with proper expiry headers.
Note that i didn't specify ?options_here - you should be careful
with query params since cache servers like squid will automatically
not cache anything with query params. this is the easiest to
the caching details to the client, but is probably the least
performant of the three options.
That will give you a nice up front boost. If the data set is large
enough that caching on the client side is really worth it, i'd start
with the json feed option, and then look into JS cookies (much
tricker to work around the 4kb limit here).
Yuval Kogman <nothingmuch at woobling.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070426/1c484289/attachment.pgp
More information about the Catalyst