# \*Don't\* cache \*anything\*. Or, why is Ajax loved so much?

**URL:** <https://www.ruby-forum.com/t/dont-cache-anything-or-why-is-ajax-loved-so-much/138178>\
**Category:** Rails\
**Created:** [May 20, 2008, 9:20pm UTC](https://www.ruby-forum.com/t/dont-cache-anything-or-why-is-ajax-loved-so-much/138178 "2008-05-20T21:20:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [May 20, 2008, 9:20pm UTC](https://www.ruby-forum.com/t/dont-cache-anything-or-why-is-ajax-loved-so-much/138178/1 "2008-05-20T21:20:26Z")

</div>

Every search I’ve done on _not caching_ something in Rails inevitably  
turns up with “so you want to cache?”. No!

I’ve got a view that is asking @cart.empty? and answering true, when I  
expect it to be false.

Calling out that cart in console yields false, as it should.

Adding and removing from the cart is done via Ajax, and the returned  
response populates the view with the cart’s items.

Refreshing said page then tells me the cart is empty.

Is this a caching issue? I haven’t explicitly setup any caching. I’m  
running in development with Thin (though I tried Mongrel with the same  
results) on Rails 2.0.2.

Any ideas?

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [May 20, 2008, 9:34pm UTC](https://www.ruby-forum.com/t/dont-cache-anything-or-why-is-ajax-loved-so-much/138178/2 "2008-05-20T21:34:25Z")

</div>

Oh, also, logger.debug messages in the controller are not displayed  
unless an Ajax request is made.

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [May 21, 2008, 2:49am UTC](https://www.ruby-forum.com/t/dont-cache-anything-or-why-is-ajax-loved-so-much/138178/3 "2008-05-21T02:49:18Z")

</div>

I’ve seen the latter happen, but only in the console. The debug  
messages (logger.debug) are written to the development.log every  
time. I’ve been using NetBeans (6.0) and in certain circumstances it  
requires the log to be closed and re-opened to see the updates to the  
log.

Have you been checking/tailing the log or just checking the console?

On May 20, 3:34 pm, Daniel W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
