Rozšíření:QuickInstantCommons
Stav rozšíření: stabilní |
|
|---|---|
| Implementace | Úložiště souborů |
| Popis | Provides a performance optimized version of InstantCommons |
| Autoři | Brian Wolff (Bawolffdiskuse) |
| Nejnovější verze | 1.5.2 |
| MediaWiki | >= 1.42 |
| PHP | >= 8.1.0 |
|
|
| Licence | GNU General Public License 2.0 nebo novější |
| Stáhnout | README |
| Přeložte rozšíření QuickInstantCommons, používá-li lokalizaci z translatewiki.net | |
| Problémy | Otevřené úkoly · Nahlásit chybu |
The QuickInstantCommons extension is a performance-optimized version of $wgUseInstantCommons.
Umožňuje také základní náhledy souborů, kterým na místní wiki chybí přípona MediaHandler.
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.
Výkon
Initial testing was done using the page en.wikipedia.org: List of governors general of Canada (revision 1054426240) which has 85 images. Testování bylo provedeno s deaktivovaným ukládáním do mezipaměti a odhadovaným TTFB pro API na již nastaveném připojení ~250 ms.
S InstantCommons jádra MediaWiki to trvalo 1 038,18 sekundy, 18,50 sekundy s tímto rozšířením se zakázaným přednačítáním a 1,10 sekundy s tímto rozšířením, ale se zapnutým přednačítáním.
Instalace
- Stáhněte soubor/y a vložte je do adresáře pojmenovaného
QuickInstantCommonsve vaší složceextensions/.
Vývojáři a přispěvatelé kódu by si místo toho měli nainstalovat rozšíření from Git pomocí:cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/QuickInstantCommons
- Na konec vašeho souboru LocalSettings.php přidejte následující kód:
wfLoadExtension( 'QuickInstantCommons' );
Dokončeno – Přejděte na stránku Special:Version vaší wiki a zkontrolujte, zda bylo rozšíření úspěšně nainstalováno.
Konfigurace
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
$wgForeignFileReposto use this extension (defaultstrue). Set tofalseif 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.
$wgQuickInstantCommonsUserAgentInfo- Contact information for the site operator. This is sent in the user-agent.
$wgQuickInstantCommonsUserAgentOverride- Fully override user-agent. Prefer to use $wgQuickInstantCommonsUserAgentInfo not this
Pokročilá konfigurace
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. If set, $wgThumbnailSteps and $wgThumbnailStepsRatio must match the foreign repo's settings.
'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.
];
$wgThumbnailSteps = [ 20, 40, 60, 120, 250, 330, 500, 960, 1280, 1920, 3840 ];
$wgThumbnailStepsRatio = 1;
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=purgeof 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.
Rate limiting with Wikimedia Commons
Recently Wikimedia Commons has implemented aggressive rate limiting which can affect this extension. To avoid this happening to you, try the following:
- Be sure to use the latest version of the extension
- Be sure to set $wgQuickInstantCommonsUserAgentInfo to include your contact information. An appropriate value might be your site name followed by a semi-colon and your email. For example
$wgQuickInstantCommonsUserAgentInfo = 'https://example.com; myname@gmail.com';. See also foundation:Policy:Wikimedia Foundation User-Agent Policy. transformVia404is now broken on MediaWiki 1.43.6 and earlier. Setting this to false may help on older versions of MediaWiki or if$wgThumbnailStepsor$wgThumbnailStepsRatiois set incorrectly. (This requires setting$wgUseQuickInstantCommonsto false and manually configuring an entry in$wgForeignFileReposas shown in #Advanced Configuration.)- Try increasing apiMetadataExpiry and descriptionCacheExpiry in the advanced ForeignFileRepo config. An appropriate aggressive value might be 1 month (2592000)
- Be sure $wgMainCacheType is set to an appropriate value that actually works.
- If you are manually configuring $wgForeignFileRepos, be sure that $wgThumbnailSteps and $wgThumbnailStepsRatio are set correctly (see above).
- If all else fails, see wikitech:Bot traffic
Související odkazy
| Toto rozšíření je zahrnuto v následujících wiki farmách/hostitelích a/nebo balíčcích: |
- Stable extensions/cs
- File repository extensions/cs
- ContentGetParserOutput extensions/cs
- ImageOpenShowImageInlineBefore extensions/cs
- GPL licensed extensions/cs
- Extensions in Wikimedia version control/cs
- All extensions/cs
- Extensions included in Canasta/cs
- Extensions included in Miraheze/cs
- Extensions included in MyWikis/cs
