Response Caching for RESTfulCF

I've just added response caching to RESTfulCF. For successful, cacheable controller actions (GET requests only), the pre-rendered response is cached, so on the next request the controller action can be completely skipped.

An example application-scope cache is provided, but you shouldn't really use this for production. But as an example of how simple it is to enable response caching, you'd first need to add the cache instance in your Dispatcher:

<cfset setCache(createobject("component", "restfulcf.framework.core.cache.ApplicationCache").init())>

Then, in the relevant Controller function, set that the response can be cached as follows:

<cfset arguments['_response'].setCacheStatus(TRUE)>

That's it, you're done! All successful (200 status code) GET requests that get routed through this controller method will now be cached.

At White Label Dating we're using a memcached-based cache for storing reporting-related requests that can take a few seconds to pull together; see the RESTfulCF README file for details on creating your own cache.

Comments
Charles's Gravatar Very interesting! Thank s a lot for posting it! it is very kind of you. You really helped me a lot improve my work with this post.
# Posted By Charles | 4/18/12 6:27 AM
Andy's Gravatar Very useful post. Thanks for sharing the script with us all. I think many people will be interested about this.
# Posted By Andy | 4/18/12 6:28 AM
Iulia's Gravatar This is very useful for me. It really did my work a lot easier. Thank yo very much for posting the script.

://www.asigurariobligatorii.net/
# Posted By Iulia | 4/18/12 6:29 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.5.006. | Protected by Akismet | Blog with WordPress