Main Menu
Lecture 1
Lecture 2
Lecture 4
Lecture 5
Lecture 6
Lecture 7
 

 

 

Problems with Browser caching

Client side caching is a useful optimisation for static pages

But can be undesirable for dynamic pages

Often you want a back or forward action in the browser to bypass the browser cache to contact the server

Without a fresh appendToResponse() the data on a page becomes stale

To enforce actions to go back to the applications server, you have to force the page to expire immediately, which prevents the browser from caching it

Global disable for all pages in Application constructor

setPageRefreshOnBacktrackEnabled(true);

To disable on individual pages for specific responses, overide appendToResponse()

response().disableClientCaching();

public void appendToResponse(WOResponse r, WOContext c) {
//custom pre-processing

//e.g. last chance to grab fresh data, build the html
super.appendToResponse(r, c);

System.out.println(" Second component append to response");

//custom post processing
//e.g. send a cookie or custom HTTP header
r.disableClientCaching();

}