Re: how to handle 4K session in camping
Bonjour, Thanks for your help. Here is how i've modified my app. now i have - a 'session' model - a sessions table with a column for my data... - a session cookie: @state[:sessionid]=SecureRandom.hex It works as wanted but i have one more question. how do you handle all the obsolete sessions in the database ? my code already delete some sessions. but some other sessions can't be deleted from the flow of my app. What are the available solutions? cron ? or something else maybe? Merci. 2013/12/7 Bluebie a...@creativepony.com If you fill the session cookie with 4kb of data, that means every http request after that to that domain will require the user to upload 4kb of data, which may not seem like much, but on a mobile phone for instance, loading a page with 50 images, that becomes 4*50 = 200kb - pretty significant considering most home internet connections do not have very fast upload in many countries. On my own internet on a good day that’s at least 2 seconds of uploading. So it is best to use session cookies only to store a very small identifier, then store more information in a local database or file. If you have a look in the rack project you’ll see some other session handlers which do exactly this, so you can keep writing data in to the ‘session’ but have it stored locally, with only a small cookie with an ID number to lookup the local data stored in to the browser. — Bluebie On Saturday, 7 December 2013 at 8:27 am, Charles McKnight wrote: Sure wish the W3C would devise a better state mechanism than cookies... On Dec 6, 2013, at 12:49 PM, Magnus Holm judo...@gmail.com wrote: You should not store a large amount of data in the session. The session is stored in a cookie, and everything you store there has to be sent back and forth over the network. You can however store an ID in the session and lookup data in your database. // Magnus Holm On Tue, Dec 3, 2013 at 12:04 PM, Francois Sery sery.franc...@gmail.com wrote: hi , i need some advices. I a little Camping app i have to store a cart in a session . i tried achieving it using the default camping/session but it is limited to 4K and my card miss some data. how can store more than 4k in a session ? thanks. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list The game's afoot. Follow your spirit, and upon this charge, cry God for Harry, England, and St. George. --- Sherlock Holmes ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: how to handle 4K session in camping
Sorry for the thread hacking but, how could be run camping as standalone CGI -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. Bluebie a...@creativepony.com escribió: Unless you’re running your camping app as a CGI script, the ruby instance keeps running, so you could just create a looping thread to do it every now and then: hours = 2 # cleanup every two hours Thread.new do loop do # some database cleanup stuff sleep hours * 60 * 60 end end The only trouble with that is you’d have it happening multiple times if you run multiple ruby servers behind a proxy like nginx, which is a pretty common configuration. Probably cron is the best way to go if you can easily do that. Otherwise you could attach it to some other event - like you could spawn a thread whenever a user logs in, which cleans up the sessions. If you wanted it to happen less frequently you could use rand() to generate a random number, then, say, cleanup if rand 0.01 if you only wanted to cleanup sessions every 1 out of 100 times someone logs in, roughly. That’s a stratergy people use a lot with systems like PHP where cron can be difficult to setup and access. I wouldn’t worry about it too much though. Your sessions will probably still be quite small (only a couple dozen kilobytes, right?) so you can probably just let them build up and then every six months or year or so go and delete all the database records that are more than a week old in that table. Storage is so cheap these days! — Bluebie On Tuesday, 10 December 2013 at 9:29 pm, Francois Sery wrote: Bonjour, Thanks for your help. Here is how i've modified my app. now i have - a 'session' model - a sessions table with a column for my data... - a session cookie: @state[:sessionid]=SecureRandom.hex It works as wanted but i have one more question. how do you handle all the obsolete sessions in the database ? my code already delete some sessions. but some other sessions can't be deleted from the flow of my app. What are the available solutions? cron ? or something else maybe? Merci. 2013/12/7 Bluebie a...@creativepony.com (mailto:a...@creativepony.com) If you fill the session cookie with 4kb of data, that means every http request after that to that domain will require the user to upload 4kb of data, which may not seem like much, but on a mobile phone for instance, loading a page with 50 images, that becomes 4*50 = 200kb - pretty significant considering most home internet connections do not have very fast upload in many countries. On my own internet on a good day that’s at least 2 seconds of uploading. So it is best to use session cookies only to store a very small identifier, then store more information in a local database or file. If you have a look in the rack project you’ll see some other session handlers which do exactly this, so you can keep writing data in to the ‘session’ but have it stored locally, with only a small cookie with an ID number to lookup the local data stored in to the browser. — Bluebie On Saturday, 7 December 2013 at 8:27 am, Charles McKnight wrote: Sure wish the W3C would devise a better state mechanism than cookies... On Dec 6, 2013, at 12:49 PM, Magnus Holm judo...@gmail.com (mailto:judo...@gmail.com) wrote: You should not store a large amount of data in the session. The session is stored in a cookie, and everything you store there has to be sent back and forth over the network. You can however store an ID in the session and lookup data in your database. // Magnus Holm On Tue, Dec 3, 2013 at 12:04 PM, Francois Sery sery.franc...@gmail.com (mailto:sery.franc...@gmail.com) wrote: hi , i need some advices. I a little Camping app i have to store a cart in a session . i tried achieving it using the default camping/session but it is limited to 4K and my card miss some data. how can store more than 4k in a session ? thanks. ___ Camping-list mailing list Camping-list@rubyforge.org (mailto:Camping-list@rubyforge.org) http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org (mailto:Camping-list@rubyforge.org) http://rubyforge.org/mailman/listinfo/camping-list The game's afoot. Follow your spirit, and upon this charge, cry God for Harry, England, and St. George. --- Sherlock Holmes ___ Camping-list mailing list Camping-list@rubyforge.org (mailto:Camping-list@rubyforge.org) http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org (mailto:Camping-list@rubyforge.org)
Re: how to handle 4K session in camping
On Mon, Nov 4, 2013 at 8:55 PM, låzaro ad...@lex-sa.cu wrote: Sorry for the thread hacking but, how could be run camping as standalone CGI -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. You can use Rack: app.cgi: #!/usr/bin/env ruby require 'rack' require 'my_app' Rack::Server::CGI.run(MyApp) ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: how to handle 4K session in camping
You should not store a large amount of data in the session. The session is stored in a cookie, and everything you store there has to be sent back and forth over the network. You can however store an ID in the session and lookup data in your database. // Magnus Holm On Tue, Dec 3, 2013 at 12:04 PM, Francois Sery sery.franc...@gmail.com wrote: hi , i need some advices. I a little Camping app i have to store a cart in a session . i tried achieving it using the default camping/session but it is limited to 4K and my card miss some data. how can store more than 4k in a session ? thanks. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: how to handle 4K session in camping
Sure wish the W3C would devise a better state mechanism than cookies... On Dec 6, 2013, at 12:49 PM, Magnus Holm judo...@gmail.com wrote: You should not store a large amount of data in the session. The session is stored in a cookie, and everything you store there has to be sent back and forth over the network. You can however store an ID in the session and lookup data in your database. // Magnus Holm On Tue, Dec 3, 2013 at 12:04 PM, Francois Sery sery.franc...@gmail.com wrote: hi , i need some advices. I a little Camping app i have to store a cart in a session . i tried achieving it using the default camping/session but it is limited to 4K and my card miss some data. how can store more than 4k in a session ? thanks. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list The game's afoot. Follow your spirit, and upon this charge, cry God for Harry, England, and St. George. --- Sherlock Holmes ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: how to handle 4K session in camping
If you fill the session cookie with 4kb of data, that means every http request after that to that domain will require the user to upload 4kb of data, which may not seem like much, but on a mobile phone for instance, loading a page with 50 images, that becomes 4*50 = 200kb - pretty significant considering most home internet connections do not have very fast upload in many countries. On my own internet on a good day that’s at least 2 seconds of uploading. So it is best to use session cookies only to store a very small identifier, then store more information in a local database or file. If you have a look in the rack project you’ll see some other session handlers which do exactly this, so you can keep writing data in to the ‘session’ but have it stored locally, with only a small cookie with an ID number to lookup the local data stored in to the browser. — Bluebie On Saturday, 7 December 2013 at 8:27 am, Charles McKnight wrote: Sure wish the W3C would devise a better state mechanism than cookies... On Dec 6, 2013, at 12:49 PM, Magnus Holm judo...@gmail.com (mailto:judo...@gmail.com) wrote: You should not store a large amount of data in the session. The session is stored in a cookie, and everything you store there has to be sent back and forth over the network. You can however store an ID in the session and lookup data in your database. // Magnus Holm On Tue, Dec 3, 2013 at 12:04 PM, Francois Sery sery.franc...@gmail.com (mailto:sery.franc...@gmail.com) wrote: hi , i need some advices. I a little Camping app i have to store a cart in a session . i tried achieving it using the default camping/session but it is limited to 4K and my card miss some data. how can store more than 4k in a session ? thanks. ___ Camping-list mailing list Camping-list@rubyforge.org (mailto:Camping-list@rubyforge.org) http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org (mailto:Camping-list@rubyforge.org) http://rubyforge.org/mailman/listinfo/camping-list The game's afoot. Follow your spirit, and upon this charge, cry God for Harry, England, and St. George. --- Sherlock Holmes ___ Camping-list mailing list Camping-list@rubyforge.org (mailto:Camping-list@rubyforge.org) http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: how to handle 4K session in camping
Hi Francis! 4K is not a limit set by Camping, as far as I know. 4K is a limit most modern browsers enforce. On Tue, Dec 3, 2013 at 12:04 PM, Francois Sery sery.franc...@gmail.comwrote: hi , i need some advices. I a little Camping app i have to store a cart in a session . i tried achieving it using the default camping/session but it is limited to 4K and my card miss some data. how can store more than 4k in a session ? thanks. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list