cache: Handle 404s and other HTTP errors as errors

Fix #4982

Review please, someone familiar with cache actions: @othiym23 @robertkowalski @dominictarr