Monday, March 05, 2012

Cache expiration module Alpha1 version released

What a pleasant surprise on a Monday morning to see the Cache expiration module release its alpha1 version, ready for basic use and testing.

Varnish, arguable the most common reverse proxy caching mechanism used with Drupal sites has integration with the Cache expiration module. With this module, it was not possible to selectively expire (purge) urls from Varnish. But now we can (atleast for some most commonly used cases).

Basic testing
Some basic testing gave very good expected results. First your Drupal setup to cache pages for anonymous users at admin/config/development/performance. Then by merely enabling the expire module, and using the default options enabled in its config page (snugged away in admin/config/development/performance/expire), you can see the benefits already:

For e.g:
Assume you have you home page cached by varnish (min cache liftime 5mins). Which means any edit to the homepage in that time will not show up to the anon user, who still sees the cached version. Unless you purge Varnish manually.

Not anymore, with the expire module enabled.

Cache expiration will purge the url of the homepage immediately, because you edited your homepage.

Good stuff already! That is not all. Here is a look at its optional features in the alpha1 release:

Optional features
  • When a node is expired their nodereferences and parent nodes where it is referenced can be expired.
  • When a 'promoted to homepage' node has been expired, the homepage can be expired.
  • Expire the menu(tree) when a node expires
  • Expire the term pages of those terms tagged to an expired node.
Note: 'expired node' refers to a node (url) that is being purged from Varnish on the event of it being edited.

Now, the wait for http://drupal.org/project/views_content_cache just got more exciting!

Friday, March 02, 2012

Coming to the pub?

Disclaimer: This is a casual topic explained in a sensitive way, meant to only clarify a point and not to judge, demean or extol anyone (myself included).

The context
I work in the UK. Here everyone goes to the pub, even if they don't drink.
Often I miss out on nice conversations and friendship because I rarely go. Even with colleagues or work-related meetup groups.

Why I don't go to the pub
I normally refuse to go to the pub, even with colleagues on official business matters, unless totally unavoidable. The reason is hardly because I don't drink. In small parts of India where religion, culture, personal and family values have mixed for a very very long time, its an insult to be seen at a pub or anywhere drinks are provided. In general, association to anything that intoxicates the mind convoluting judgement is bad. That include smoking, drugs and hedonistic pursuits that corrupt the individual for the individual's or society's sake.

My family included, we stay away as much as we can from the above. Of course, its not meant to say all those who drink or smoke are bad for example. But as a matter of strictness, we stay away since even appearing to encourage or being spotted at such places constitute a part of moral sin!

The only way I can explain is with an anology, albeit at a much larger scale, just because its easy to understand. I assure you its not as blown up as whats coming hereforth nor to judge people wrongly, but its only an analogy meant to prove my reasoning.

Consider how others would perceive you if you were to be spotted in a brothel. Even if you were not there for their services and were simply accompanying a friend (do people do that?). Almost all of us are concerned of how we would be perceived by the society, even total strangers. So for most of us, we would stay well away to avoid personal scandals and rumours and insults and the like.

Its the same case, at a much lower level. Drinking is traditionally looked down upon from where I come. Suffice to say it speaks lowly of oneself. Hence I need to deter away from watering holes, to spare the rod! So do many many others who may not be able to explain adequately.

So, "coming to the pub?" Erm no. But thanks!

Thursday, November 24, 2011

JW Player module now supports plugins

The JW Player module, which is currently in development for Drupal 7 has just got the feature of being able to support plugins for presets. With this feature, it is possible to plug in all the add ons availabe from Longtail video.

JW Player plugins

There is also a Drupal preset plugin created for Google Analytics Pro2 JW player available in my sandbox. Custom modules can implement plugins by using the newly introduced hook_jw_player_plugin_info() in the JW Player module. The format to use this hook as described in jw_player.api.php is:

/**
 * Implements hook_jw_player_plugin_info()
 *
 * @return array Associative array of plugins keyed by actual plugin id
 */
function hook_jw_player_plugin_info($preset) {
  // Create a plugin keyed by its actual plugin id
  $plugins['foo'] = array(
    'name' => t('Foobar'),
    'description' => t('A plugin to do foobar'),
    // Note: Each option should be in a valid FAPI format, as it is directly referenced in the preset settings form,
    // except the '#title' may be omitted for the name of the option to be taken as default
    'config options' => array(
      'accountid' => array(
        '#type' => 'textfield',
        '#required' => TRUE,
        '#size' => 15,
        '#default_value' => 'bar'
      ),
      'param2' => array(
        '#type' => 'select',
        '#options' => array('TRUE' => 'TRUE', 'FALSE' => 'FALSE'),
        '#default_value' => 'TRUE',
        '#description' => t('Enables the controls on an item when playing')),
    ),
  );
  return $plugins;
}

As described above, the plugin is an associative array keyed by its actual plugin name as required by the player. The data basically consists of a friendly name and description, followed by configurable options that the site-administrator/editor can set per preset, which would look something like:

JW Player preset settings
If the preset plugin is enabled, when viewing the source code of your page that contains a JW Player video, you should be able to see the plugin added to the player code; something like: