and I would love to have an environment setting to turn off view
caching while on my dev machines in the same way we can do wioth event
and/or handler caching... but I cannot seem to find one other than
executing a clearAllViews() in each request?
For development environment stuff, I often make a interceptor that is only registered within my dev environment. Then, you can clear the template cache at the start/end of each request.
Thanks Aaron - I'll give your blog post a lookover!
I think a config setting similar to the handler and event caching bool
would be a great addition to the configure API. By the way
getColdBoxOCM().clearAllViews() on onRequestStart does *not* seem to
work...
In ColdBox 3 we have two cache regions: default ( for objects and data) and template (views and event caching). This provides flexibility to choose where items get stored and how and in what cache. Therefore, to interact you are talking to the wrong provider.
getColdBoxOCM(“template”) or
getCacheBox().getCache(“template”)
Yeah you want to do something like this in your interceptor:
var cacheName = arguments.event.getTrimValue(“cbox_cacheName”,“default”); log.debug(“postProcess fired, clearing all views”); getColdboxOCM(cacheName).clearAllViews();
Then I can switch the cacheViews flag based on the environment pretty easily. I try (try being the key word) to do a setting for anything I would want to switch per environment because it is so nice and easy to do.
@Doug - what I did was to only register that interceptor in my
development() function on Colbox.cfc @Curt - good idea... I will play with that idea too... see whch I like
the best!
I like to clear the cache using the interceptor instead of stopping
caching completely as I want to know that the caching mechanism is
working. If I set caching off then it would never be used in
development only in production which would worry me. With the
interceptor I can also clear other things from the cache besides
objects in the template cache if I want to.
Also, when I cache views I tend to use the additional settings so I'd
have something like this: