I'm creating a website that has two basic user groups: Subscribers and Editors. Bot can create posts via a custom form using wp_insert_post(), but Editors are allowed to mark a post as private, effectively sharing a single post only among other Editors.

As Wordpress already filters private posts out of the loop for anyone lower than Editors, i'm wondering how this will affect my caching because (as far as I understand) I'll have two caches: one showing posts to Subscribers, and one showing posts to Editors which also includes private posts.

Within the loop I'm using:

  • current_user_can(): to include or exclude some post content based on Subscriber/Editor/Administrator
  • get_post_status(): to include or exclude some post content based on if the post is "private" or "published"
  • get_post_meta(): to retrieve various custom fields

Right now I'm using 26 queries in 0.198 seconds on index.php and 28 queries in 0.193 seconds on single.php.

How would one effectively cache this? I don't have any caching plugin yet but I do have access to xCache.

Many thanks!

没有正确的解决方案

许可以下: CC-BY-SA归因
scroll top