• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
disableClientCaching Direct Actions and Safari's 'Back' button
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

disableClientCaching Direct Actions and Safari's 'Back' button


  • Subject: disableClientCaching Direct Actions and Safari's 'Back' button
  • From: Jake Macmullin <email@hidden>
  • Date: Wed, 2 Mar 2005 10:04:32 +1100

Greetings All,

I'm working on an application where I want to allow the use of the back button - except I want to make sure that when a user hits the back button it actually causes my WebObjects application to generate a fresh response (rather than get the page out of a client-side cache or some proxy in between). The reason I want to prevent people from using cached pages is that I'm keeping track of a list of selections in the Session - and displaying the list on every page. I want users to be able to browse around - click on links to add things to the list, then be able to use the back button to return to the 'previous' page - but it should reflect the fact that they've added something else to the list since last time they viewed that 'page'. I'm also using Direct Actions.

My understanding is that for a non-Direct Action application, all I'd have to do is to call setPageRefreshOnBacktrackEnabled(true); in my Application constructor. However, I seem to recall someone mentioning that this doesn't apply to pages generated by Direct Actions - so I thought I'd override appendToResponse and call disableClientCaching.

However, after much trial and error I found this wasn't enough to stop all browsers from caching the page, so I added explicitly set some headers in my implementation of appendToResponse:

    public void appendToResponse(WOResponse r, WOContext c) {
        super.appendToResponse(r,c);
        r.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT");
        r.setHeader("Cache-Control","no-store"); //HTTP 1.1
        r.setHeader("Pragma","no-cache"); //HTTP 1.0
    }

This *still* wasn't enough for Safari though! - In order to convince Safari not to cache pages, I ended up adding an 'invisible' frame to each page that I don't want to have cached (as desribed in this faq: http://developer.apple.com/internet/safari/faq.html#anchor5)

<iframe style="height:0px;width:0px;visibility:hidden" src="about:blank">
this frame prevents back forward cache
</iframe>


After all of that - I *think* I've got the behaviour I want - but I wanted to check to see if there was an easier way. How has everyone else dealt with this? Also, is there anything else I need to be aware of?

Regards,

Jake MacMullin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: JFreeChart in WO
  • Next by Date: Re: JFreeChart in WO
  • Previous by thread: Re: JFreeChart in WO
  • Next by thread: Re: attempt to assign value to unknown key
  • Index(es):
    • Date
    • Thread