[Wikitech-l] Cache Expiry

2011-06-08 Thread Robert Cummings
Hello,

I've looked around for methods to manipulate the cache duration for a
given article. There are methods to facilitate the expiration of an
article, and there are extensions that can disable caching for articles
via convenient management interfaces. What seems to be lacking though,
is a way to expire the article after some duration. For instance, I'm
working with embedded RSS feeds... from what I'm finding I have 3 options:

  1. Live with the RSS feed being cached.
  2. Immediately invalidate the article cache so that the next
 request causes the article to be rebuilt.
  3. Tell users to use action=purge (or provide a button to
 manually do this (or invalidate the cache).

The first option is not really an option :) The second option is
inefficient. The third option is unpalatable.

So the question becomes-- Would it be possible to have a new field added
to the page database table that determines the duration of the cache?
This would be optimal because extensions could then auto determine the
maximum duration of the article either by directly manipulating the
table entry, or preferably via a hook when the article is saved.

Failing a change to the MediaWiki core, I guess I could create a service
extension that uses it's own database table to track durations and
checks for expirations via the job system at which time it could
invalidate articles. But that seems roundabout for something that
strikes me as better supported in the core.

Thoughts?

Cheers,
Rob.
-- 
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Wikitech-l] Cache Expiry

2011-06-08 Thread Brion Vibber
On Wed, Jun 8, 2011 at 1:50 PM, Robert Cummings rob...@interjinn.comwrote:

 I've looked around for methods to manipulate the cache duration for a
 given article. There are methods to facilitate the expiration of an
 article, and there are extensions that can disable caching for articles
 via convenient management interfaces. What seems to be lacking though,
 is a way to expire the article after some duration. For instance, I'm
 working with embedded RSS feeds...

[snip]

It looks like MediaWiki 1.17 and later support this already, by calling
updateCacheExpiry() on the parser cache output object.

The RSS extension uses this in its rendering hook:

if ( $wgRSSCacheCompare ) {
$timeout = $wgRSSCacheCompare;
} else {
$timeout = $wgRSSCacheAge;
}

$parser-getOutput()-updateCacheExpiry( $timeout );

In theory at least this should propagate the shorter expiry time out to both
the parser cache entry and the actual output page's HTTP headers, though I
haven't tested to double-check myself yet.

-- brion
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Wikitech-l] Cache Expiry

2011-06-08 Thread Robert Cummings
On 11-06-08 05:02 PM, Brion Vibber wrote:
 On Wed, Jun 8, 2011 at 1:50 PM, Robert Cummingsrob...@interjinn.comwrote:

 It looks like MediaWiki 1.17 and later support this already, by calling
 updateCacheExpiry() on the parser cache output object.

 The RSS extension uses this in its rendering hook:

  if ( $wgRSSCacheCompare ) {
  $timeout = $wgRSSCacheCompare;
  } else {
  $timeout = $wgRSSCacheAge;
  }

  $parser-getOutput()-updateCacheExpiry( $timeout );

 In theory at least this should propagate the shorter expiry time out to both
 the parser cache entry and the actual output page's HTTP headers, though I
 haven't tested to double-check myself yet.

Great, that appears to be what I was looking for... I'll go explore the 
code now :)

Thanks,
Rob.
-- 
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l