History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CACHE-134
Type: Improvement Improvement
Status: Closed Closed
Resolution: Duplicate
Priority: Major Major
Assignee: Unassigned
Reporter: Bin Sun
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
OSCache

<oscache:cache> always creates HttpSession, which is undesired.

Created: 27/Jan/05 12:13 AM   Updated: 27/Jan/05 03:35 PM
Component/s: None
Affects Version/s: 2.1
Fix Version/s: None

Issue Links:
Duplicate
This issue duplicates:
CACHE-88 Don't create session object in cache ... Minor Closed
 


 Description  « Hide
When I use oscache to cache a frequently visited page, and added
<%@page session="false" %>
in the head, I saw sessions still created.

When I trace session creation with a HttpSessionListener, I found the <oscache:cache> tag always creates the session, in the following code fragment of ServletCacheAdministrator.java:

public Cache getCache(HttpServletRequest request, int scope) {
        if (scope == PageContext.APPLICATION_SCOPE) {
            return getAppScopeCache(request.getSession(true).getServletContext());
        }

if (scope == PageContext.SESSION_SCOPE) {
            return getSessionScopeCache(request.getSession(true));
        }

throw new RuntimeException("The supplied scope value of " + scope + " is invalid. Acceptable values are PageContext.APPLICATION_SCOPE and PageContext.SESSION_SCOPE");
    }

Since the page is visited by enormous users, I want the session creation to be forbidden. Could OSCACHE improve this?

 All   Comments   Change History      Sort Order:
Bin Sun - [27/Jan/05 12:40 AM ]
I've updated oscache2.1 source to solve this problem (BTW, it's a pity that there's no build.xml in the downloaded package):

com.opensymphony.oscache.web.CacheTag.java, inserted 1 line before line 444:

pageContext.getRequest().setAttribute("_ServletContext4OSCache_",pageContext.getServletContext());

com.opensymphony.oscache.web.ServletCacheAdministrator.java, modified line 220:

return getAppScopeCache((ServletContext) request.getAttribute("_ServletContext4OSCache_"));

Bin Sun - [27/Jan/05 12:53 AM ]
another file need to be patched:
FlushTag.java, line 130, insert:

pageContext.getRequest().setAttribute("_ServletContext4OSCache_",pageContext.getServletContext());

and line 220 of ServletCacheAdministrator.java should be better changed to :

ServletContext context = (ServletContext) request.getAttribute("_ServletContext4OSCache_");
            return getAppScopeCache(context != null ? context : request.getSession(true).getServletContext());