Fragment Caching in WordPress

Mark on WordPress

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.

View original post

New blog

After 2008 shutdown I was missing a public and non-useful place for my random rants on coding as well as other cool things, news, links and so on.

Even worse I was lacking a proper account. Unacceptable.
That’s the true story behind this new URL: no real reason but curiosity, at least now.

Feel free to check out my  WordPress plugins while I think something cool to write! 🙂