Meza/Ensuring users get the latest file

= The problem = after you "Upload a new version of this file" for an image .. pages that use scaled versions of the image do not automatically get new the new image without some manual per-page coercing by the users .. how can you guarantee that users will always see the "current version" of an image after it has been updated?

= The solution = tools and solutions listed so far include;
 * 1) https://httpd.apache.org/docs/current/mod/mod_expires.html
 * 2) https://wikitech.wikimedia.org/wiki/Tool:Stashbot
 * 3) Tuning MW when using "img_auth.php"
 * 4) Resolve Bug: https://phabricator.wikimedia.org/T19577
 * 5) configure a for images, and use the headers module to add headers http://httpd.apache.org/docs/current/mod/mod_headers.html#header
 * 6) https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control has other caching possibilities

Which of these options and how to configure them is still a topic of discussion. If you have any specific solution that works for you.. please contribute to this page. = Options =

Option 1 - Extension:WikiDexFileRepository
using: https://github.com/ciencia/mediawiki-extensions-WikiDexFileRepository In Localsettings: wfLoadExtension( 'WikiDexFileRepository' ); $wgLocalFileRepo = [ 'class' => 'LocalWikiDexRepo', 'name' => 'local', 'directory' => $wgUploadDirectory, 'url' => $wgUploadBaseUrl ? $wgUploadBaseUrl. $wgUploadPath : $wgUploadPath, 'hashLevels' => 2, 'thumbScriptUrl' => $wgThumbnailScriptPath, 'transformVia404' => true, 'deletedDir' => $wgDeletedDirectory, 'deletedHashLevels' => 3 ]; this extension adds extra "/latest/ " to the image/file path before the filename, which must be stripped out by rewrite rules in .htaccess

Such as the following for NGINX map $mwuploads_longcache $mwuploads_expire { default 5m; 1 30d; }

map $uri $images_thumbfallback { default @404; "~/mwuploads/wikidex/" @thumb; }

map $uri $images_mwinstallpath { default "/dev/null"; "~/mwuploads/wikidex/" "/home/www/www.wikidex.net/mediawiki-1.30"; }

map $request_uri $thumbfile { default "xx"; "~/mwuploads/[a-z0-9]+/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/latest/[0-9]+/(? [^/]+)/[0-9]+px-.*$" "$xthumbfile"; "~/mwuploads/[a-z0-9]+/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/(? [^/]+)/[0-9]+px-.*$" "$xthumbfile"; "~/mwuploads/[a-z0-9]+/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/(? [^/]+)/[0-9]+px-.*$" "$xthumbfile"; } server {

location /mwuploads/ { alias /data/mwuploads/public/; expires $mwuploads_expire;

# Imagen con /latest/timestamp/, se reescribe, expires largo location ~ "^/mwuploads/[a-z0-9]+/(?:thumb/)?[0-9a-f]/[0-9a-f][0-9a-f]/latest/[0-9]+/.*$" { set $mwuploads_longcache 1; expires $mwuploads_expire; rewrite "^/mwuploads/(? [a-z0-9]+/(?:thumb/)?[0-9a-f]/[0-9a-f][0-9a-f]/)latest/[0-9]+/(? .*)$" "/mwuploads/$startpath$endpath"; }

# Imagen directa en /archive, expires largo location ~ "^/mwuploads/[a-z0-9]+/archive" { set $mwuploads_longcache 1; expires $mwuploads_expire; }		# Imagen thumb # Ojo, las variables del regexp se usan en @thumb location ~ "^/mwuploads/[a-z0-9]+/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/[^/]+/(? [0-9]+)px-.*$" { set $thumbarchived 0; expires $mwuploads_expire; try_files $uri $images_thumbfallback; }		# Imagen thumb de archive location ~ "^/mwuploads/[a-z0-9]+/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/[^/]+/(? [0-9]+)px-.*$" { set $mwuploads_longcache 1; set $thumbarchived 1; expires $mwuploads_expire; try_files $uri $images_thumbfallback; }	}

location @thumb { expires $mwuploads_expire; # Run the thumb.php script include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $images_mwinstallpath/thumb.php; fastcgi_param QUERY_STRING f=$thumbfile&width=$thumbwidth&archived=$thumbarchived; fastcgi_pass unix:/run/php/php-fpm-wikidex-images.sock; }

location @404 { return 404; }

location / { return 404; } }