I have this working now -- there are probably better/tidier ways of
doing it (feedback most welcome) but for what it's worth:
In your handler declare an init method if there isn't one already
<cffunction name="init" access="public" returntype="any"
output="false">
<cfscript>
// set event cache suffix for multi-lingual
caching
this.EVENT_CACHE_SUFFIX = getFWLocale();
return this;
</cfscript>
</cffunction>
This takes care of caching at the locale level. If you have content
that isn't user specific but IS locale specific (say a common header
which has language elements in it) then this is all you need.
To go one step further and make it specific to a session (for example
a header which says "Welcome {Username}") you need to cache at the
view level. I decided not to append my session ID to the event cache
suffix as that would remove the ability to cache once for ALL users,
not just one.
Declare an onRequestStart event handler if there isn't one already
(coldbox config). Insert these two lines:
// set cache suffix for this user
prc.userCacheSuffix = "_" & getFWLocale() & "_" & session.sessionid;
prc.userCacheTimeout = 40; // minutes
that will result in a string you can use as a cache suffix which will
be unique for a given session/locale combination. I set the timeout to
40 minutes since my sessions time out in 30... I figure that's safe.
To cache a view you need to specify the cacheTimeout and cacheSuffix
arguments:
#renderView(view='layoutsnippets/template_header', cache=true,
cacheTimeout=prc.userCacheTimeout, cachesuffix=prc.userCacheSuffix)#
If you open up the cachebox monitor now any view you cached using the
above method should have an entry like this in the TEMPLATES cache:
cbox_view-layoutsnippets/
template_header_en_us_8efbf6b9602070995344f01dc59d2093_13900_96287697
If there's a nicer/better/easier way of doing this I'm all ears, but
this appears to work ok.