views:

880

answers:

2

This is a new gmail labs feature that lets you specify an RSS feed to grab random quotes from to append to your email signature. I'd like to use that to generate signatures programmatically based on parameters I pass in, the current time, etc. (For example, I have a script in pine that appends the current probabilities of McCain and Obama winning, fetched from intrade's API. See below.) But it seems gmail caches the contents of the URL you specify. Any way to control that or anyone know how often gmail looks at the URL?

Thanks!

ADDED: Here's the program I'm using to test this. This file lives at http://kibotzer.com/sigs.php. The no-cache header idea, taken from here -- http://mapki.com/wiki/Dynamic_XML -- seems to not help.

<?php

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
//XML Header
header("content-type:text/xml");
?>

<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd"&gt;
<rss version="0.91">
<channel>
<title>Dynamic Signatures</title>
<link>http://kibotzer.com&lt;/link&gt;
<description>Blah blah</description>
<language>en-us</language>
<pubDate>26 Sep 2008 02:15:01 -0000</pubDate>
<webMaster>[email protected]</webMaster>
<managingEditor>[email protected] (Daniel Reeves)</managingEditor>
<lastBuildDate>26 Sep 2008 02:15:01 -0000</lastBuildDate>

<image>
<title>Kibotzer Logo</title>
<url>http://kibotzer.com/logos/kibo-logo-1.gif&lt;/url&gt;
<link>http://kibotzer.com/&lt;/link&gt;
<width>120</width>
<height>60</height>
<description>Kibotzer</description>
</image>

<item>
<title>
Dynamic Signature 1 (<?php echo gmdate("H:i:s"); ?>) 
</title>
<link>http://kibotzer.com&lt;/link&gt;
<description>This is the description for Signature 1 (<?php echo gmdate("H:i:s"); ?>) </description>
</item>

<item>
<title>
Dynamic Signature 2 (<?php echo gmdate("H:i:s"); ?>) 
</title>
<link>http://kibotzer.com&lt;/link&gt;
<description>This is the description for Signature 2 (<?php echo gmdate("H:i:s"); ?>) </description>
</item>

</channel>
</rss>
--
http://ai.eecs.umich.edu/people/dreeves  - -  search://"Daniel Reeves"

Latest probabilities from intrade...
  42.1%  McCain becomes president (last trade 18:07 FRI)
  57.0%  Obama becomes president (last trade 18:34 FRI)
  17.6%  US recession in 2008 (last trade 16:24 FRI)
  16.1%  Overt air strike against Iran in '08 (last trade 17:39 FRI)
+1  A: 

You might be able to do something on the clientside, take a look at this greasemonkey script which randomly adds a signature. Since it's under your control, and not google's, you can control if it caches or not.

davr
Thanks! Good point. I have in mind an application for normal users though and I figure greasemonkey is somewhat of a hurdle for them. Would be nice if they could just specify a URL in their settings...
dreeves
I think there's also a way of bundling a greasemonkey script into a standalone firefox plugin. I don't know how involved it is.
davr
+1  A: 

Try setting the Cache-Control: no-cache and Pragma: no-cache HTTP headers. If Google's signature code honors either of these headers then you'll be in luck.

sherbang
Good idea. Just tried, but, alas, as far as I can tell, it is not honoring either of them. (I may have done that wrong though.)
dreeves
How did you test this? They would need to re-request your signature before they would see the no-cache flag. I kind-of expect them to be ignoring this though, for some reason I imagine them fetching this asynchronously and caching the result. You may get some control over cache time with max-age
sherbang