See proposals on bug 41130.
Purge requests are based on the file in the backend, not those in the cache. If they fall out of sync (like if a prior purge is partially completed), then there can be unpurgable images in the cache.
One solution is to use a varnish module to hash all thumbnails for an original version of a file to the same place so that they can all be purged at once. This could be based on a thumbnail url regex, since the source file is the parent directory of the thumbnail.
If a file had 1 current and 2 old versions, the thumbnails would be mapped to 3 different hashes for that file, one for each version. Purge requests could be issues for each of the original versions on ?action=purge (or file deletion and other events) which purge all thumbnails for those 3 versions regardless of what thumbnails are in the backend vs cache.
Version: unspecified
Severity: normal
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=41130
https://bugzilla.wikimedia.org/show_bug.cgi?id=48927