Interceptor preProcess gets cache?

Hi guys,

I have an interceptor with a preProcess method, containing the
following simple code:

<!-- init vars -->
<cfset var domainbase = #cgi.http_host# />

<!-- init structs -->
<cfset prc.whitelabel = StructNew()/>

<!-- logic -->
<cfif domainbase IS 'www.domain.com'>
<cfset prc.whitelabel.client = 'DOMAINVALUE' />
<cfelseif domainbase IS 'www.sub.domain.com'>
<cfset prc.whitelabel.client = 'SUBDOMAINVALUE' />
</cfif>

In home I cfoutput the value: prc.whitelabel.client

The first time I enter home it outputs: 'DOMAINVALUE' as it should,
same for the subdomain, the first time I enter it outputs:
'SUBDOMAINVALUE'

But if I return to my interceptor and change either the domainvalue or
the subdomainvalue, and refresh the home, it shows the previous value,
not the new one, if I add ?fwreinit=true the new value shows up, but
I though that the preProcess intercepts everything first , right?

Is this the way preProcess should be working? or somehow is getting
cache?

Thanks in advance

Felipe Serrano

Try OnRequestCapture instead. I *think* pre-process is after
OnRequestCapture in the request lifecycle...

Hello Tom,

Ok, the OnRequestCapture should be created in the same interceptor?

Thanks in advance

Felipe Serrano

Yes it's just a different interception point.

As far as I know, OnRequestCapture is the only point in the request
lifecycle that happens before cacheBox does its thing; anything after that,
and it's too late - it gets cached.

Bear in mind, that anything you add into the RC within OnRequestCapture,
will alter the hashed RC - so you get a different cached event.

Really, from looking at your code (and being presumptuous) I'd put your
whiteLabel struct into the RC - not the PRC. The PRC doesn't get hashed, and
therefore both sites will use the same cached key and see the same thing -
if that's not what you want, then I'd use the RC instead.

If you put your whiteLabel struct into the RC, the cached key will be
different for all sites/subdomains, and they'll basically see different
cached versions of the pages - essentially sandboxing the cache for the
different domains.

Tom.

Thank lots Tim, for your comments and suggestions!

Let me run some tests!

Felipe Serrano

Did just what you said, and it works the same as the preProcess,
changed values do not get reflected until I use the ?fwreinit

Thank you though :slight_smile:

Will look into to another method.

Felipe Serrano

As I said, put them in the RC. The PRC doesn't get hashed, so colbox sees
the event as identical.

Hi, yes I move them to RC

Thanks again
Felipe Serrano

And now it works?

Sorry, Im not very good explaining myself,
Yes and No, I crate the intercetor method onRequestCapture, it works
fine as in preProcess
the same issue (which probabbly it is not) is happening,

If I change values in rc.whitelabel.client, it does keep using the
previous instead until I use fwreinit
but since, that value it will never change since it will be a constant
for each subdomain. It will work.

I found strange that rc.whitelabel.client in either onRequestCapture
or preProcess, do not reflect change suntil using fwreinit, but
probabbly, that is how it should be, don't know.

Thanks Tom! :slight_smile:

Felipe Serano

If you are caching the view (i.e event.setview(view="myview", cache=true) -
it will *always* cache unless you set a cacheprefix for the view
specifically, for instance event.setView(view="myview", cache=true,
cacheprefix="#rc.whitelabel.client#").

If you are caching the event itself, it will use what's in the rc to create
the cachekey. Essentially, event caching creates the cachekey by doing
hash(serializeJSON(toString(rc))) - so the cache key would change as soon as
a variable is added into the RC.

Hope that helps.

Tom.

Thanks for the feed back again Tom,

Let me check that up!

:slight_smile:

Felipe Serrano