OK, problem solved sufficiently for now.

(1) The workaround is to set

$.ajaxSetup({
  cache: false
});

Then ?_=<timestamp> is added to each AJAX request, so a new request
hits the server each time. As it's a fresh XHR request, I'm not
getting the wrong "HTML" (non-XHR) version of the page inserted. This
is good enough for me.

(2) I also partially figured out why loading jQuery causes the 'back'
button to behave differently. It's down to this code:

// Prevent memory leaks in IE
// And prevent errors on refresh with events like mouseover in other
browsers
// Window isn't included so as not to unbind existing unload events
jQuery( window ).bind( 'unload', function(){
        for ( var id in jQuery.cache )
                // Skip the window
                if ( id != 1 && jQuery.cache[ id ].handle )
                        jQuery.event.remove( jQuery.cache
[ id ].handle.elem );
});

If you comment this out, then it works as expected. Pressing 'back'
just goes back to the page as it was, without triggering all the ready
() functions again. This is good for both perceived speed and reduced
load on the server.

However, I don't know why binding to window.unload would make this
happen. It seems to be more like an accidental side-effect. I wonder
if anyone is relying on this behaviour in practice?

I have submitted a ticket and test case at http://dev.jquery.com/ticket/5198

Regards,

Brian.

Reply via email to