Spam and DoS prevention were actually the original purpose of Proof of Work. Hashcash, the first (I think) anti-spam PoW algorithm, was what Bitcoin's PoW algorithm was inspired by.
Or, the server provides a random string of bits with length n and requires a string of bits with length n+m that starts with the provided n bits and whose SHA-1 hash begins with 20 zero bits.