# Efficient ajax calls using flash?

**URL:** <https://www.ruby-forum.com/t/efficient-ajax-calls-using-flash/72823>\
**Category:** Rails\
**Created:** [October 19, 2006, 5:53am UTC](https://www.ruby-forum.com/t/efficient-ajax-calls-using-flash/72823 "2006-10-19T05:53:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [October 19, 2006, 5:53am UTC](https://www.ruby-forum.com/t/efficient-ajax-calls-using-flash/72823/1 "2006-10-19T05:53:40Z")

</div>

Hey guys,

I do an ajax call to update a div in my view with a different partial.  
The new partial uses data that was originally queried when the page was  
loaded. It is kinda redundant to have to requery that record again.

Is the best solution to use flash to pass the result set. I guess, my  
question is,

Does flash get stored on the client side, or on the server side.

If its only the client side then flashing would make sense.

On the other hand, if I am just requerying the database using the “ID”  
field, isn’t that ultra fast and takes very little resources where it  
wont matter if I just requery for that specific result?

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [October 19, 2006, 9:10am UTC](https://www.ruby-forum.com/t/efficient-ajax-calls-using-flash/72823/2 "2006-10-19T09:10:57Z")

</div>

In other words, is it worth using the select statement from a result  
statement instead of requerying that specific item using find(id)?

Eric G. wrote:

> Hey guys,
> 
> I do an ajax call to update a div in my view with a different partial.  
> The new partial uses data that was originally queried when the page was  
> loaded. It is kinda redundant to have to requery that record again.
> 
> Is the best solution to use flash to pass the result set. I guess, my  
> question is,
> 
> Does flash get stored on the client side, or on the server side.
> 
> If its only the client side then flashing would make sense.
> 
> On the other hand, if I am just requerying the database using the “ID”  
> field, isn’t that ultra fast and takes very little resources where it  
> wont matter if I just requery for that specific result?

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [October 19, 2006, 2:23pm UTC](https://www.ruby-forum.com/t/efficient-ajax-calls-using-flash/72823/3 "2006-10-19T14:23:39Z")

</div>

The other option would be to store it in the session(not the flash -  
that doesn’t stick around between requests), but if you’re using the  
database as the session store, then it’s the same thing. You Could also  
insert the ID or whatever you need to store into the AJAX params, that  
way it would be “stored” in the HTML on the client machine.

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [October 19, 2006, 10:49pm UTC](https://www.ruby-forum.com/t/efficient-ajax-calls-using-flash/72823/4 "2006-10-19T22:49:37Z")

</div>

1.) Neither Flash nor Session are stored on the client machine. They are  
all  
on the server.

2.) By default, rails stores session information on the filesystem. This  
is  
fine, unless you need to share sessions across servers in which case you  
can  
have Rails store session data in the database. It’s easy if you want to  
go  
that route. Google it.

3.) Yes, running a one-item query by ID is the easiest thing a DB server  
can  
do. Unless you want to do :select =\> ‘SQL\_CACHE \*’ which will do a  
cached  
query, thus increasing database speed as much as humanly possible.

Jason

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [October 20, 2006, 1:12am UTC](https://www.ruby-forum.com/t/efficient-ajax-calls-using-flash/72823/5 "2006-10-20T01:12:59Z")

</div>

Thanks for your response Jason.

So which route would you go in the case of ajax calls, would you flash  
over the orginal result set? Or would you just pass the id and query  
that from the database? Or is one way not really better than the other?

Im trying to build my app to be as scalable as possible.

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [October 19, 2006, 9:05pm UTC](https://www.ruby-forum.com/t/efficient-ajax-calls-using-flash/72823/6 "2006-10-19T21:05:39Z")

</div>

What do you mean using the database as the session store? On this note,  
is there any advantage to using flash with flash.keep across actions as  
opposed to session? Is it less “resource intensive” or bulky to use  
flash or does it not matter since its both stored on the clients  
machine.

So Jason, what I understand from your response is that by storing the ID  
and requerying that specific entry from the database using find is  
really negligable as far as taking up database querying resources?

Jason N. wrote:

> The other option would be to store it in the session(not the flash -  
> that doesn’t stick around between requests), but if you’re using the  
> database as the session store, then it’s the same thing. You Could also  
> insert the ID or whatever you need to store into the AJAX params, that  
> way it would be “stored” in the HTML on the client machine.
