also your echo $thefield
needs escaping, I know you stored some HTML in that option using code that you wrote but what if it was something else? What if it actually contained <script>alert("buy crypto here");</script>
or something malicious? I'd also be mindful of what it is you're caching, HTML is super easy and cheap to generate, it's figuring out what the data is that's expensive, aka which post was 1 year ago, so you'd be much better off storing a post ID instead