Extension:QuickInstantCommons

The QuickInstantCommons extension is a performance-optimized version of. It also allows basic thumbnailing of files that are missing a MediaHandler extension on the local 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.

Performance
Initial testing was done using the page en.wikipedia.org: List of governors general of Canada (revision 1054426240) which has 85 images. Testing was done with caching disabled and an estimated TTFB for the API on an already setup connection of ~250ms.

It took 1038.18 seconds with MediaWiki core's InstantCommons, 18.50 seconds with this extension with prefetching disabled, and 1.10 seconds with this extension with prefetching enabled.

Configuration
If you were previously using, no configuration is needed beyond  -ing this extension; configuration is only required for advanced usage.


 * Automatically set up  to use this extension (defaults true). Set to false if you need to customize something.
 * Automatically set up  to use this extension (defaults true). Set to false if you need to customize something.


 * 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.
 * 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.


 * Max number of images to prefetch if prefetching is enabled (default: 1000). Could hit OOM issues if too high.
 * Max number of images to prefetch if prefetching is enabled (default: 1000). Could hit OOM issues if too high.

Advanced Configuration
You can directly configure  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:

is probably the most important value from a performance perspective (other then ). 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 (1 month)

Differences between this and ForeignApiFileRepo

 * Caches curl handle
 * Uses HTTP/2 multiplexing (Major performance boost)
 * 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.

Known issues

 * If you are using Extension:TimedMediaHandler, you need to use at least MediaWiki 1.38 for this extension to work with video files.