Blocks like slabs or glass panes placed in a grid pattern can effectively stop spiders from spawning in a mob farm. These blocks create a physical barrier that spiders cannot bypass.