Jump to content

Extension:ScheduledCacheExpiry

From mediawiki.org
MediaWiki extensions manual
ScheduledCacheExpiry
Release status: beta
Implementation Parser function
Description Adds parser functions for controlling a page's parser cache expiry.
Author(s) Universal Omega
Latest version 1.0.0
MediaWiki 1.46+
Database changes No
Licence GNU General Public License 3.0 or later
Download GitHub

The ScheduledCacheExpiry extension lets editors control how long a page's parsed output can remain cached. This is useful for pages containing time-sensitive content, such as showing birthdays messages.

Installation

[edit]
  • Download and place the file(s) in a directory called ScheduledCacheExpiry in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'ScheduledCacheExpiry' );
    
  • Configure as required.
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Usage

[edit]

Update daily

[edit]
{{#cachedaily:}}

Sets a cache lifetime of 24 hours from when the page is parsed.

Update at specified times

[edit]

The parser function below sets the cache expiry time to 03:00 in the configured timezone.

{{#cacheuntil:03:00}}

To specify more than one time, separate them with commas:

{{#cacheuntil:03:00,15:00}}

Note that the minimum cache expiry time still applies. If a page is parsed 10 seconds before the chosen time, while the minimum cache expiry is 6 hours, then the page's cache will be invalidated in 6 hours instead of 10 seconds.

Update after a fixed interval

[edit]

The example below sets a cache expiry of 6 hours from when the page is parsed.

{{#cacheinterval:21600}}

The number is in seconds. Values below the configured minimum in $wgScheduledCacheExpiryMinimumExpiry are raised to that minimum.

Configuration

[edit]
$wgScheduledCacheExpiryMinimumExpiry
Minimum cache expiry time in seconds.
Default: 60.
$wgScheduledCacheExpiryTimezone
Timezone used to interpret #cacheuntil times, for example 'America/New_York'. An invalid timezone name falls back to UTC. This setting is independent of each reader's timezone preferences.
Default: 'UTC'.

See also

[edit]