if (response != null && (response.headerForKey(ERXSession.DONT_STORE_PAGE) != null || (response.userInfo() != null && response.userInfo().objectForKey(ERXSession.DONT_STORE_PAGE) != null))) { String pageCacheKey = response.headerForKey(ERXSession.PAGE_REPLACEMENT_CACHE_LOOKUP_KEY);
if (shouldNotStorePage(response) || shouldNotStorePage(request) || request.formValueForKey("AJAX_SUBMIT_BUTTON_NAME") != null) { String pageCacheKey = null; if (response != null) { pageCacheKey = response.headerForKey(ERXSession.PAGE_REPLACEMENT_CACHE_LOOKUP_KEY); } if (pageCacheKey == null && request != null) { pageCacheKey = request.headerForKey(ERXSession.PAGE_REPLACEMENT_CACHE_LOOKUP_KEY); }
  public void savePage(WOComponent page) {    WOContext context = context();    WOResponse response = context.response();    if (response != null && (response.headerForKey(ERXSession.DONT_STORE_PAGE) != null || (response.userInfo() != null && response.userInfo().objectForKey(ERXSession.DONT_STORE_PAGE) != null))) {      String pageCacheKey = response.headerForKey(ERXSession.PAGE_REPLACEMENT_CACHE_LOOKUP_KEY);      if (pageCacheKey != null) {        String originalContextID = context.request().headerForKey(ERXSession.ORIGINAL_CONTEXT_ID_KEY);        pageCacheKey = originalContextID + "_" + pageCacheKey;        // System.out.println("ERXSession.savePage: " + pageCacheKey + " starting (contextid = " + context.contextID() + ")");        LinkedHashMap pageReplacementCache = (LinkedHashMap) objectForKey(ERXSession.PAGE_REPLACEMENT_CACHE_KEY);        if (pageReplacementCache == null) {          pageReplacementCache = new LinkedHashMap();          setObjectForKey(pageReplacementCache, ERXSession.PAGE_REPLACEMENT_CACHE_KEY);        }        // Remove the oldest entry if we're about to add a new one and that would put us over the cache size ...        // We do a CACHE_SIZE*2 here because for every page, we have to potentially store its previous contextid to prevent        // race conditions, so there technically can be 2x cache size many pages in the cache.        boolean removedCacheEntry = cleanPageReplacementCacheIfNecessary(pageCacheKey);        if (!removedCacheEntry && pageReplacementCache.size() >= ERXSession.MAX_PAGE_REPLACEMENT_CACHE_SIZE * 2) {          Iterator entryIterator = pageReplacementCache.entrySet().iterator();          Map.Entry oldestEntry = (Map.Entry) entryIterator.next();          entryIterator.remove();          //System.out.println("ERXSession.savePage: " + pageCacheKey + " removing oldest entry = " + ((TransactionRecord)oldestEntry.getValue()).key());        }        TransactionRecord pageRecord = new TransactionRecord(page, context, pageCacheKey);        pageReplacementCache.put(context.contextID(), pageRecord);        //System.out.println("ERXSession.savePage: " + pageCacheKey + " new context = " + context.contextID());        //System.out.println("ERXSession.savePage: " + pageCacheKey + " = " + pageReplacementCache);      }    }    else {      super.savePage(page);    }  }