Riding a terrible bridleway (deep large horse marks in dry mud), I broke a spoke on the 20 spoke rear wheel so I decided to fit a new 28 spoke wheel and there was a new 9s 11-40 cassette for £23... so we had to try it
I have a sora short cage derailleur which is specified for 30 teeth max but the cage has the same dimensions as the altus M310 specified for 32 max... In the past, with these derailleurs, I rode without any issue with a Sora 11-34 cassette and Sunrace or Acera 11-36...
With 11-40 I knew I was pushing the limits but ..
11-36 silver and 11-40 black
Once the cassettes were swapped, no real drama; it worked well but out of conscience, I adjusted the "B" screw to improve the jump between 34 and 40 (V1 and V2).
Then, ~22Km of mountain biking just to test. The first 5 minutes, I made some adjustments with the cable tension screws.
Then, I went for it ("shredded" as the trendy kids say) in the mud
Result, it works well for me... better for big muddy hills, I have better grip.