Skip to content

Commit

Permalink
allow client-side caching of ERXResponse content
Browse files Browse the repository at this point in the history
  • Loading branch information
nur-sgaertner committed Feb 7, 2014
1 parent 6dc9dca commit 0eb850f
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ public static class Context {
private LinkedHashMap<String, Integer> marks;
private Stack<Object> _contentStack;
private WOContext _context;
private boolean _allowClientCaching;

public ERXResponse() {
_allowClientCaching = false;
}

/**
Expand Down Expand Up @@ -207,22 +209,41 @@ public static ERXResponse popPartial() {

/**
* Overridden to <b>not</b> call super if trying to download an attachment
* to IE.
* to IE or if allowClientCaching is <code>true</code>.
*
* @see com.webobjects.appserver.WOResponse#disableClientCaching()
*
*/
@Override
public void disableClientCaching() {
boolean isIEDownloadingAttachment = isIE() && isAttachment() && !isHTML();
if (!isIEDownloadingAttachment) {
if (!isIEDownloadingAttachment && !_allowClientCaching) {
//NSLog.out.appendln("Disabling client caching");
super.disableClientCaching();
}
else {
//NSLog.out.appendln("Allowing IE client caching");
}
}

/**
* Can be used to enable client-side caching of the response content,
* for example if the response contains a static image.
* Normally it will be prevented by {@link #disableClientCaching()}.
* Note that additionally you might need to set the cache-control header.
*
* @param allowClientCaching <code>true</code> prevents calling {@link #disableClientCaching()}
*/
public void setAllowClientCaching(boolean allowClientCaching) {
this._allowClientCaching = allowClientCaching;
}

/**
* @return <code>true</code> if client-side caching shall be allowed
*/
public boolean allowClientCaching() {
return _allowClientCaching;
}

/**
* @see #DisablePageCachingKey
Expand Down

0 comments on commit 0eb850f

Please sign in to comment.