Mobs keep dying?

I’m on a realm on mcpe, trying to display some cave spiders behind glass. They kept climbing up and dropping, injuring themselves to death, so I added vines to the walls and water to fall in. Still, they don’t survive 10 minutes after being captured. Any tips for an aspiring spider wrangler?

Does minecraft have like a soft block I can use? For example would slimeblocks work? Or would they kill them even sooner?

Should I put blocks above glass?