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

Key: CACHE-67
Type: Improvement Improvement
Status: Reopened Reopened
Priority: Minor Minor
Assignee: Lars Torunski
Reporter: Alex Burgel
Votes: 1
Watchers: 3
Operations

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

On caching pages with session IDs in URLs

Created: 21/Nov/03 10:55 AM   Updated: 21/Jan/07 01:53 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 3.0

File Attachments: 1. Text File sessionid.patch (8 kb)



 Description  « Hide
I'd like to collect thoughts on caching session IDs in URLs (jsessionid).

As far as I can tell, OSCache does not support this, and the current non-support could lead to some security problems on poorly configured systems (i.e. caching a page with a session id and later redisplaying it).

An idea on how to support this are as follows:

1. use some combination of request.isRequestSessionIdFromCookie and request.getSession to tell if this page could have session encoded URLs

2. if thats the case, scan through the content replacing the session ID with a special token

3. cache the page

4. when retrieving from the cache, replace the token with the current session id.

all very straight forward, but an important issue pops up.

what if the cached page doesn't have encoded URLs (i.e. the first user to view had cookies on), then there's no easy way to know which URLs to re-encode for the next non-cookie user.

the two solutions i see are:

1. prepopulate the cache with encoded URLs, then for cookie users, just strip the whole thing off.

2. keep 2 versions in the cache, 1 with the session token and 1 without.

i'm not sure how to do the first one, and the second one is a bit wasteful...

does anyone else have ideas? or other issues?

i think i'll try to tackle this once i get a clearer picture of what the best solution is.

 All   Comments   Change History      Sort Order:
Alex Burgel - [03/Dec/03 04:39 PM ]
this patch modifies OScache to correctly work with pages containing session ids encoded in URLs.

its a first attempt, so its not well tested. it only fixes the behavior of the taglibs, not the cache filter.

Alex Burgel - [03/Dec/03 04:52 PM ]
a few notes on the patch.

it works by treating pages with session ids in URLs as separate pages. when it comes across one of these pages, it strips out the ID and replaces it with a token, then when its serving the page, it'll replace the token with the current session id. this means that you'll have 2 versions of each page in your cache.

as i said above, it only works with the taglibs... and it might even break the filter. i don't use the filter, so i haven't tested. fixing the filter is a bit more involved because it stores the content as a byte array, and there might be character encoding issues if you have to scan through the array to find the session ids.

as for finding the session ids, it searchs for '

Alex Burgel - [03/Dec/03 04:54 PM ]
hmm, seems you can't put html in the comments.

what i meant to say at the end was:

it searchs for

Alex Burgel - [03/Dec/03 04:55 PM ]
man! you can't even put in semi-colons!!

for the last time, what i meant to say at the end was:

it searchs for jsessionid= and then a contiguous string of letters or digits. it might be better if it only searched within html tags... but thats something i can add later

Lars Torunski - [13/Mar/05 04:18 PM ]
This issue should be implemented after the CacheFilter changes in release 2.2 proved to be stable.

Lars Torunski - [11/Sep/05 12:04 PM ]
As a workaround you can use the "sessionIdInURL" value of the "nocache" parameter in the CacheFilter of OSCache 2.2 (http://wiki.opensymphony.com/display/CACHE/CacheFilter).