扩展:QuickInstantCommons
QuickInstantCommons 发行状态: 稳定版 |
|
---|---|
实现 | 文件存储库 |
描述 | Provides a performance optimized version of InstantCommons |
作者 | Brian Wolff (Bawolff留言) |
最新版本 | 1.5 |
MediaWiki | >= 1.42 |
PHP | >= 7.4.3 |
许可协议 | GNU通用公眾授權條款2.0或更新版本 |
下載 | README |
|
|
季度下載量 | 87 (Ranked 63rd) |
前往translatewiki.net翻譯QuickInstantCommons扩展 | |
問題 | 开启的任务 · 报告错误 |
The QuickInstantCommons extension is a performance-optimized version of $wgUseInstantCommons
.
此扩展也可以在本地wiki缺少媒体处理器扩展的情况下展示基本的缩略图。
For example, the first page of a PDF will still thumbnail even without Extension:PdfHandler installed, but advanced features like multipage requires that extension to be installed locally.
性能
Initial testing was done using the page en.wikipedia.org: List of governors general of Canada (revision 1054426240) which has 85 images. 测试时禁用了缓存,在已设置的连接上,API 的估计TTFB为~250ms。
使用MediaWiki core的InstantCommons需时 1038.18 秒,禁用预取时使用该扩展需时 18.50秒,启用预取时使用该扩展需时1.10秒。
安裝
- 下载文件,并将解压后的
QuickInstantCommons
文件夹移动到extensions/
目录中。
开发者和代码贡献人员应从Git安装扩展,输入:cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/QuickInstantCommons - 将下列代码放置在您的LocalSettings.php 的底部:
wfLoadExtension( 'QuickInstantCommons' );
- 完成 – 在您的wiki上导航至Special:Version,以验证已成功安装扩展。
配置
If you were previously using $wgUseInstantCommons
, no configuration is needed beyond wfLoadExtension
-ing this extension; configuration is only required for advanced usage.
$wgUseQuickInstantCommons
- Automatically set up
$wgForeignFileRepos
to use this extension (defaultstrue
). Set tofalse
if you need to customize something. $wgQuickInstantCommonsPrefetch
- Enable prefetching images based on what's in DB (default: true). Most of the time this is a major performance boost, but its possible that occasionally this might cause work to be done that isn't necessary.
$wgQuickInstantCommonsPrefetchMaxLimit
- Max number of images to prefetch if prefetching is enabled (default: 1,000). Could hit OOM issues if too high.
高级配置
You can directly configure $wgForeignFileRepos
if you want.
For example, if you want to use this extension with a wiki that is not Commons.
It is also required if you want to use this at the same time as normal instant commons (not reccomended).
Example:
wfLoadExtension( 'QuickInstantCommons' );
$wgUseQuickInstantCommons = false;
$wgForeignFileRepos[] = [
'class' => '\MediaWiki\Extension\QuickInstantCommons\Repo',
'name' => 'commonswiki', // Must be a distinct name
'directory' => $wgUploadDirectory, // FileBackend needs some value here.
'apibase' => 'https://commons.wikimedia.org/w/api.php',
'hashLevels' => 2, // Important this matches foreign repo if 404 transform enabled.
'thumbUrl' => 'https://upload.wikimedia.org/wikipedia/commons/thumb', // Set to false to auto-detect
'fetchDescription' => true, // Optional
'descriptionCacheExpiry' => 43200, // 12 hours, optional (values are seconds). This cache is not adaptive.
'transformVia404' => true, // Whether foreign repo supports 404 transform. Much faster if supported
'abbrvThreshold' => 160, // must match what foreign repo uses if 404 transform enabled. Default is 255. Wikimedia uses 160.
'apiMetadataExpiry' => 60*60*24, // Max time metadata is cached for. Recently changed items are cached for less
'disabledMediaHandlers' => [TiffHandler::class] // media handler extensions to not use. For 404 handling its important that the local media handler extensions match the foreign ones.
];
apiMetadataExpiry
is probably the most important value from a performance perspective (other then $wgQuickInstantCommonsPrefetch
).
If you feel things are slow, try increasing it.
If a new version of a file is uploaded, it might not show up properly until after metadata expires.
However you can force an expiry by purging the file description page on the local wiki.
If you want to maximize performance, an appropriate value might be 60*60*24*30 = 2,592,000 (1 month)
ForeignAPIRepo
, $wgResponsiveImages
should not impact performance when transformVia404 is enabled, so it is recommended that you keep it turned on.false
for the extension to try and auto-detect.Differences between QuickInstantCommons and ForeignApiFileRepo
- Caches curl handle
- Uses HTTP/2 multiplexing (Major performance boost)
?action=purge
of File pages purges image metadata- Does not support local thumbnail caching
- Automatically generate thumbnail URLs locally if foreign repository supports 404 handling (Major performance boost, especially when responsive images are enabled)
- Prefetch expected images based on imagelinks table (Major performance boost)
- Allows limited thumbnailing of files that are missing handler extension (e.g. Still show thumbnail of first page of a PDF even if you don't have Extension:PdfHandler installed).
- Adaptive TTL support that actually works (If the foreign image was recently edited, cache for shorter time, so that if its vandalism the revert will show up faster).
- Configurable metadata caching time, with better defaults than core.
- When using a foreign repo that itself has foreign repos (For example, how en.wikipedia.org includes commons.wikimedia.org), image page descriptions will now work correctly.
- File redirects for files that are foreign files on the foreign repo work.
- Allows disabling media handlers that are incompatible and use fallback behaviour instead.
- For images that can't use 404 rendering (missing local media handler extension or if transformVia404 false), predictively prefetches the responsive high-dpi thumbnails
- Reuse HTTP/2 connection for fetching description page text
- Do not show text of 404 if the description page is missing on foreign wiki. Instead just show it as blank.
Other ideas that haven't been implemented: better adaptive cache for image description pages.
已知問題
- If you are using Extension:TimedMediaHandler, you need to use at least MediaWiki 1.38 for this extension to work with video files.
- If you get an error about undefined constant and the constant name has CURL in it, please ensure that the php curl extension is using at least version 7.43.0 of curl.
參見
此扩展在以下wiki农场/托管网站和/或软件包中提供: 這不是一份權威名單。 即使某些wiki农场/托管网站和/或软件包未在这里列出,它们也可能提供此扩展。 请检查你的wiki农场/托管网站或软件包以确认提供情况。 |
- Stable extensions/zh
- File repository extensions/zh
- GPL licensed extensions/zh
- Extensions in Wikimedia version control/zh
- ContentGetParserOutput extensions/zh
- ImageOpenShowImageInlineBefore extensions/zh
- All extensions/zh
- Extensions included in Miraheze/zh
- Extensions included in MyWikis/zh
- Extensions included in WikiForge/zh