Fragment caching is useful for caching HTML snippets that are expensive to generate and exist in multiple places on your site. It’s like full page HTML caching, but more granular, and it speeds up dynamic views.

I’ve been using this fragment caching class for a few years now. I optimized it around ease of implementation. I wanted, as much as possible, to be able to identify a slow HTML-outputting block of code, and just wrap this code around it without having to refactor anything about the code inside.

Implementation is pretty easy, and you can reference the comment at the start of the code for that. The only thing to consider is that any variables that alter the output need to be build into the key. It should also be noted that this code assumes you have a persistent object cache backend.

brief:
1. Loading your own copy of jQuery
2. Not loading JS/CSS files properly
3. Not escaping user input in SQL and not encoding user input on output
4. Incorporating too many 3rd Party Services
5. Expecting too much from shared hosting
6. Using “admin” for a username with an insecure password
7. Adding tons of plugin-type functionality to a theme’s functions.php