# Back button behavior has changed again in Safari 3.1, after doing a dom update via ajax/RJS

**URL:** <https://www.ruby-forum.com/t/back-button-behavior-has-changed-again-in-safari-3-1-after-doing-a-dom-update-via-ajax-rjs/132413>\
**Category:** Rails\
**Created:** [March 19, 2008, 10:26pm UTC](https://www.ruby-forum.com/t/back-button-behavior-has-changed-again-in-safari-3-1-after-doing-a-dom-update-via-ajax-rjs/132413 "2008-03-19T22:26:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yuval](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/977dab/32.png) [@Yuval](https://www.ruby-forum.com/u/Yuval)\
**Post date:** [March 19, 2008, 10:26pm UTC](https://www.ruby-forum.com/t/back-button-behavior-has-changed-again-in-safari-3-1-after-doing-a-dom-update-via-ajax-rjs/132413/1 "2008-03-19T22:26:42Z")

</div>

GAH!

Here is the firefox behavior, which is perfect:

1. View page 1
2. Update some text by using link\_to\_remote or remote\_form\_for, along  
with an RJS replace or replace\_html
3. Navigate to page 2
4. Hit back
5. Page was cached with dom updates, note that the page is show in the  
same state as it was left

Safari 3.0 behavior  
1…4) repeat  
5) Page reloads, ending up in the state where it was left

Safari 3.1 behavior:  
1…4) repeat  
5) Page was cached WITHOUT dom updates, page is shown in unaltered  
state until refresh is hit

I thought I’d give it a shot with changing my status inline on  
facebook, then navigating away and back, and noticed that the page  
does reload and the dom updates are there.

Advice appreciated.

---

<div class="post-metadata">

**Author:** ![Yuval](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/977dab/32.png) [@Yuval](https://www.ruby-forum.com/u/Yuval)\
**Post date:** [March 20, 2008, 2:18pm UTC](https://www.ruby-forum.com/t/back-button-behavior-has-changed-again-in-safari-3-1-after-doing-a-dom-update-via-ajax-rjs/132413/2 "2008-03-20T14:18:05Z")

</div>

I have tried adding various caching headers to the response object  
with no success.

---

<div class="post-metadata">

**Author:** ![Yuval](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/977dab/32.png) [@Yuval](https://www.ruby-forum.com/u/Yuval)\
**Post date:** [March 24, 2008, 12:39am UTC](https://www.ruby-forum.com/t/back-button-behavior-has-changed-again-in-safari-3-1-after-doing-a-dom-update-via-ajax-rjs/132413/3 "2008-03-24T00:39:34Z")

</div>

Anyone else encountering this? It appears to be a history issue, as  
cache settings have had no effect.

---

<div class="post-metadata">

**Author:** ![Yuval](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/977dab/32.png) [@Yuval](https://www.ruby-forum.com/u/Yuval)\
**Post date:** [April 17, 2008, 1:29am UTC](https://www.ruby-forum.com/t/back-button-behavior-has-changed-again-in-safari-3-1-after-doing-a-dom-update-via-ajax-rjs/132413/4 "2008-04-17T01:29:40Z")

</div>

Do you have a small, reproducible test case for this?

---

<div class="post-metadata">

**Author:** ![Yuval](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/977dab/32.png) [@Yuval](https://www.ruby-forum.com/u/Yuval)\
**Post date:** [April 20, 2008, 7:20pm UTC](https://www.ruby-forum.com/t/back-button-behavior-has-changed-again-in-safari-3-1-after-doing-a-dom-update-via-ajax-rjs/132413/5 "2008-04-20T19:20:17Z")

</div>

Ouch. After much testing, I think I’ve found the problem:

I have an iframe in my layout appliation.html.erb, which I use with  
attachment\_fu and responds\_to\_parent for ajaxy uploading of  
attachments. It’s required for my app. Funny enough, the first place I  
read about the iFrame remoting pattern was on Apple’s site, but now  
it’s Apple’s browser that seems to have a problem with it.

It looks like this:

The iFrame appears to be forcing the page to load in its original  
state when clicking back to it after navigating away. Not sure what to  
do at this point but will keep at it.

---

<div class="post-metadata">

**Author:** ![Yuval](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/977dab/32.png) [@Yuval](https://www.ruby-forum.com/u/Yuval)\
**Post date:** [April 18, 2008, 4:00pm UTC](https://www.ruby-forum.com/t/back-button-behavior-has-changed-again-in-safari-3-1-after-doing-a-dom-update-via-ajax-rjs/132413/6 "2008-04-18T16:00:02Z")

</div>

I’ll put together a small code sample.

---

<div class="post-metadata">

**Author:** ![Yuval](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/977dab/32.png) [@Yuval](https://www.ruby-forum.com/u/Yuval)\
**Post date:** [April 21, 2008, 6:07am UTC](https://www.ruby-forum.com/t/back-button-behavior-has-changed-again-in-safari-3-1-after-doing-a-dom-update-via-ajax-rjs/132413/7 "2008-04-21T06:07:39Z")

</div>

Well, I’ve managed to get around the problem by dynamically creating  
and destroying the iframe via a javascript onsubmit for the requisite  
forms. Problem solved for now. Though I have noticed other instances  
of safari history weirdness related to ajax that are unrelated to the  
iframe issue. The fun continues…
