2

I've been really confused about these two caching modes. What's the main difference between fragment caching and wp_cache? Can both of them be used hand in hand?

EDIT

I've read about the fragment caching found in the link commented by @Steven. I just want to know what's there difference and which one to use for better performance.

2
  • I don't know enough about caching to post an answer, but have you seen this article? css-tricks.com/wordpress-fragment-caching-revisited ?
    – Steven
    Commented Feb 19, 2016 at 13:18
  • @Steven, yeah, i did stumble upon that material and it was really helpful. It only explains how fragment caching though. I think i wanted to know the difference between both of them and which one to use. Commented Feb 19, 2016 at 13:23

1 Answer 1

2

I'll post this as an answer, even though I don't know much about caching.

If you read about WP Object Cache it says:

By default, the object cache is non-persistent. This means that data stored in the cache resides in memory only and only for the duration of the request. Cached data will not be stored persistently across page loads unless you install a persistent caching plugin.

From what I understand from the article by Ryan Burnette, you can set the caching time yourself.

Fragment caching takes the output of a code block and stores it so for a predetermined amount of time. When the code runs, as long as the time limit hasn't elapsed, the block is ignored and the stored output is returned and printed onto the page.

We'll know soon if I'm completely off the mark here :)

5
  • Okay. @Steven I think that sounds easy to understand. It seems that fragment caching can help a lot with the optimization of the page load. Am i right? Commented Feb 19, 2016 at 13:35
  • Definitely. Especially if your query is a bit heavy. You save server request, server load and it saves time because you don't have to fetch the data from the server. I don't use custom cache for simple sites. But you can consider using the plugin wp-super-cache.
    – Steven
    Commented Feb 19, 2016 at 13:39
  • Thank you, @Steven. I have this taxonomy page that queries all the post under it and it determines whether the post is a video, a single image or a gallery, and it have a quite complicated logic. You think i can use fragment caching in it? Commented Feb 19, 2016 at 13:44
  • You can use caching for any data that is returned. But when it comes to taxonomies, I'm not that technical. Sorry :)
    – Steven
    Commented Feb 19, 2016 at 13:53
  • 1
    That's alright. But i guess i can use it to for my wp_query in my taxonomy. Thanks anyway @Steven Commented Feb 19, 2016 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.