Disabling caching in Apache Shindig

I’m currently working on a project that involves the use of the Apache Shindig OpenSocial container. As you may know Shindig relies heavily on caching, which is no surprise considering where Shindig originally came from (i.e. iGoogle, with millions of users).

While caching is generally a good thing it’s a pain in the *** during gadget development. There are various ways to disable Shindig caches but the most convenient way is to disable EHCache altogether. Note that Shindig also ships with a simple LRU cache but for production purposes EHCache is recommended. During development you can easily disable EHCache by setting the following system property in your container:

-Dnet.sf.ehcache.disabled=true

During startup you’ll see the following log messages which indicate nothing will be cached.

WARN [net.sf.ehcache.Cache] Cache: expressions is disabled because the net.sf.ehcache.disabled property was set to true. No elements will be added to the cache.
WARN [net.sf.ehcache.Cache] Cache: parsedCss is disabled because the net.sf.ehcache.disabled property was set to true. No elements will be added to the cache.
WARN [net.sf.ehcache.Cache] Cache: messageBundles is disabled because the net.sf.ehcache.disabled property was set to true. No elements will be added to the cache.
WARN [net.sf.ehcache.Cache] Cache: gadgetSpecs is disabled because the net.sf.ehcache.disabled property was set to true. No elements will be added to the cache.
WARN [net.sf.ehcache.Cache] Cache: cajoledDocuments is disabled because the net.sf.ehcache.disabled property was set to true. No elements will be added to the cache.
WARN [net.sf.ehcache.Cache] Cache: parsedDocuments is disabled because the net.sf.ehcache.disabled property was set to true. No elements will be added to the cache.
WARN [net.sf.ehcache.Cache] Cache: httpResponses is disabled because the net.sf.ehcache.disabled property was set to true. No elements will be added to the cache.

Speaking of caching in Shindig, note that Shindig caches HTTP calls made through gadget.io.makeRequest() by default. This may be useful when building a social network but it’s not much use when employed in an enterprise environment. In a typical enterprise application you probably don’t want to cache the response of every HTTP call made to the backend.

You can easily disable this behavior by editing  ehcache.xml in Shindig. Just change the value of the “maxElementsInMemory” attribute in the httpResponses cache to 1 (see this gist). Now every HTTP call in production to backend systems will pass through.

Please use the comment section below if you have any questions or tips!

  • Facebook
  • LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>