Title: Comments in 4.6 can now be cached by a persistent object cache
Author: Rachel Baker
Published: July 18, 2016

---

 [  ](https://profiles.wordpress.org/rachelbaker/) [Rachel Baker](https://profiles.wordpress.org/rachelbaker/)
8:15 pm _on_ July 18, 2016     
Tags: [4.6 ( 140 )](https://make.wordpress.org/core/tag/4-6/),
[comments ( 27 )](https://make.wordpress.org/core/tag/comments/), [dev-notes ( 647 )](https://make.wordpress.org/core/tag/dev-notes/)

# Comments in 4.6 can now be cached by a persistent object cache

The ‘comment’ cache group was made non-persistent in [[7986]](https://core.trac.wordpress.org/changeset/7986),
to address the difficulty of reliable cache invalidation. This meant the comment
cache values were only held for the current page load, and lost on reload or navigation.
The comment APIAPI An API or Application Programming Interface is a software intermediary
that allows programs to interact with each other and share data in limited, clearly
defined ways. has improved since WordPress 2.6, and _cache is king_.

In WordPress 4.6 the ‘comment’ cache group has been removed from the list of non-
persistent cache groups, see [[37613]](https://core.trac.wordpress.org/changeset/37613).
When comments are added, modified, or deleted we properly invalidate out of date
cache values. You can now cache with confidence.

If you have a pluginPlugin A plugin is a piece of software containing a group of
functions that can be added to a WordPress website. They can extend functionality
or add new features to your WordPress websites. WordPress plugins are written in
the PHP programming language and integrate seamlessly with WordPress. These can 
be free in the WordPress.org Plugin Directory [https://wordpress.org/plugins/](https://wordpress.org/plugins/)
or can be cost-based plugin from a third-party. which modifies comment data directly
please change them to make use of the various comment API functions or use `[clean_comment_cache()](https://developer.wordpress.org/reference/functions/clean_comment_cache/).`

Don’t _miss_ out on this change. For more background on the change, see [#36906](https://core.trac.wordpress.org/ticket/36906).

[#4-6](https://make.wordpress.org/core/tag/4-6/), [#comments](https://make.wordpress.org/core/tag/comments/),
[#dev-notes](https://make.wordpress.org/core/tag/dev-notes/)

### Share this:

 * [  Threads ](https://make.wordpress.org/core/2016/07/18/comments-in-4-6-can-now-be-cached-by-a-persistent-object-cache/?share=threads)
 * [  Mastodon ](https://make.wordpress.org/core/2016/07/18/comments-in-4-6-can-now-be-cached-by-a-persistent-object-cache/?share=mastodon)
 * [  Bluesky ](https://make.wordpress.org/core/2016/07/18/comments-in-4-6-can-now-be-cached-by-a-persistent-object-cache/?share=bluesky)
 * [  X ](https://make.wordpress.org/core/2016/07/18/comments-in-4-6-can-now-be-cached-by-a-persistent-object-cache/?share=x)
 * [  Facebook ](https://make.wordpress.org/core/2016/07/18/comments-in-4-6-can-now-be-cached-by-a-persistent-object-cache/?share=facebook)
 * [  LinkedIn ](https://make.wordpress.org/core/2016/07/18/comments-in-4-6-can-now-be-cached-by-a-persistent-object-cache/?share=linkedin)

 1. ![](https://secure.gravatar.com/avatar/d7f59286b1dd707bfcfa8b4f4ce492be2b79973271369c91e4ce39e56eea3289?
    s=32&d=mm&r=g)
 2.  [programmin](https://profiles.wordpress.org/programmin/)  12:41 am _on_ July 27,
    2016
 3. Will this improve the case where having many thousands of comments pending (from
    an unprotected form for example) will cause out-of-memory fatal errors because 
    it loads an array of all comments when trying to manage them on /wp-adminadmin (
    and super admin)/?
 4. ![](https://secure.gravatar.com/avatar/85cd797876de53531b77ed37565fcf9fd5a7bae47d5139120cec9f63d17b706b?
    s=32&d=mm&r=g)
 5.  [Luke Cavanagh](https://profiles.wordpress.org/lukecavanagh/)  9:20 pm _on_ November
    7, 2016
 6. @programmin
 7. Not sure but using an object cache, will store that DB query regardless of type
    of the query. So if using an object cache like Memcached or Redis it should.

Comments are closed.

# Post navigation

[← This Week in 4.6: July 18 – 24](https://make.wordpress.org/core/2016/07/18/this-week-in-4-6-july-18-24/)

[Week In Core, July 12 – July 19 2016 →](https://make.wordpress.org/core/2016/07/20/week-in-core-july-12-july-19-2016/)