Force page reload on back/forward button in Firefox 3.x

When using the back/forward buttons in FF3.x, pages are cached and delivered from cache very strictly. Obviously (unlike normal caching) even page headers like Pragma, Expires etc. are ignored. This special cache is often referred to as bfcache (back/forward cache).

This behavior caused exceptions in my wicket app, where ajax funtionality is used, here’s what happens:
* Load page containing panelA
* User interaction, replacing panelA with panelB using ajax
* User clicks back button
* User clicks forward button
-> initial page content (markup) is loaded from fbcache, including panelA
-> in wicket pageMap, panelA is not existent, since it has been replaced with panelB
* User interacts with an ajax element on panelA
-> exception is thrown “Component x not found on page”

Solution: add an unload handler to the page’s body tag. This causes firefox to reload the page instead of simply grabbing it from bfcache, so that server and client side state is in sync again 🙂

Advertisements

Tags: , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: