• Skip to content
  • Skip to primary sidebar
  • Skip to footer

Foliovision

Main navigation

  • Weblog
    • FV Player
    • WordPress
    • Video of the Week
    • Case Studies
    • Business
  • About
    • Testimonials
    • Meet the Team
    • We Support
    • Careers
    • Contact
    • Pricing
  • Products
  • Support
    • FV Player Docs
    • Pro Support
  • Login
  • Basket is empty
Affordable VAST/VPAID for Wordpress has arrived. Serve ads with your videos starting today!

Comment Caching Models to improve WordPress Core Performance

10 March 2017 / Martin / 1 Comment

Many of our clients don’t like the paged comments feature of WordPress as they like to have all the keywords occurring in the comments present on our article page and not spread across multiple pages. Keeping thousands of fresh comments on the page with every possible combination of keywords helps them rank at the top of Google for very competitive product categories.

Our front-end comment moderation plugin Thoughtful Comments includes comment caching feature, this article describes why that is important even if you are caching your site HTML: Improve your WordPress speed by Caching Comments.

However the downside is that it doesn’t work for administrators and that the cache has to be purged and rebuilt when comments are added or removed. It’s also usually slows down logged in users as we move more and more of our clients over to a membership or at least logged in user model.

Quest of speeding up the comments display

We sought alternative ways of speeding up the comments by simplifying the PHP code required to display each comment. Here are all the filters running on comment text and how much they contribute to the total PHP processing time for comments.  

 Filter Name Description Required
 wptexturize Converts regular quotes to fancy quotes etc. No, it’s eyecandy
 convert_chars Escapes HTML special chars. Yes
 make_clickable Makes the plain text links clickable. Yes
 force_balance_tags Makes sure HTML in comment text won’t break the page layout. Yes 
 convert_smilies Converts text smileys to Emojis No! 
 wpautop Puts in paragraph breaks. Yes 

In our test enviromnent 781 comments take ~1.52 seconds to display. When all of the above filters are disabled, it’s ~1.35 seconds (12% gain) and when the absolutely needed filters are kept (without them the comment wouldn’t appear properly – no links or line breaks) it’s ~1.43 seconds (6% gain). So that’s not much.

Comment with all filters
Comment with all filters
Comment with just the required filters
Comment with just the required filters

Comment author, date, etc.

Big part of comment HTML are the meta information. We checked how much could be saved on each by removing that part of markup and found the issues: 

Information Description of the issue Estimate of savings
Comment Date It’s called 3 times for each comment with a lot of formatting going on 13%
Comment Link The link is mostly just the ID of the element 12%
Edit Link Comment editing permissions are checked for each comment 7%

With all of these improvements and reduced comment text filtering 781 comments on our test post load in ~ 0.986 seconds (35% speed increase).

These improvements could be implemented in a form of a simplified comment display callback function – Documentation on WordPress.org.

Fragment caching

The speed benefits of the above are clear, and they do help. We would still like to make the comment load not 35% faster, but lightning fast.

We tried to cache each comment individually rather than caching the whole list of comments. Advantages of this approach would be:

  • cache doesn’t have to be cleared when
    • posting a new comment
    • removing a comment
    • approving a comment
    • and so on
  • same cache files could be used for admins – just the “Edit” comment link would have to be put in using JavaScript

We would like this new function to work as seamless as possible, so we checked where it could be stored – here is are the average speed values for comparison of different comment caching options.

 Caching mode First load [s] Repeated loads [ms]
no caching 1.655  
single file 1.716 46
comment meta 3.2 46.6
custom database table 2.8 28
individual file for each comment 2.014 42
  1. Single file – this is that’s currently done in FV Thoughtful Comments
  2. Comment meta – much slower than caching into a file, unfortunately. We confirmed this on two different servers with different Apache + MySQL configs
  3. Custom database table – faster than using comment meta, but all the database inserts still take its toll. Also, not sure why the display here would be faster than the other caching models, but we were able to replicate the behavior or different servers
  4. Individual file for each comment – unfortunately still slower than using a single cache file. We are not sure about all the implications of this for multiple webhead website serving, but this is probably the solution for us.

Other interesting options might be using Memcache or Redis. However this kind of cached data should have a very long TTL. So the most resilient yet very high performance model is to cache each comment separately. Which is what we are going to do in the latest Thoughtful Comments

Martin Vicenik

Martin Viceník

Martin graduated as an engineer in Computer Science from Slovak Technical University in Bratislava. He grew up in Liptovský Mikuláš in northern Slovakia next to the beautiful Tatra mountains. He is the developer behind our FV Player.

Categories: WordPress

Related Posts

  1. Improve your WordPress speed by Caching Comments

  2. WordPress Comment Ratings Plugins Roundup: Zaki vs Ulike vs Comment Vote vs Voter vs Thumbs Rating vs GD Rating System

  3. How to alter WordPress comment email

    How to alter WordPress comment email

Reader Interactions

Comments

  1. Mediaku 7 January 2019 at 11:07 am

    Thankss… very helpful.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You can click here to Subscribe without commenting

Primary Sidebar

Categories

  • Business
  • Camera Reviews
  • Case Studies
  • Design
  • FV Player
  • Internet Marketing
  • IT
  • Life
  • SEO
  • Slovak
  • Video of the Week
  • WordPress

Footer

Our Plugins

  • FV WordPress Flowplayer
  • FV Thoughtful Comments
  • FV Simpler SEO
  • FV Antispam
  • FV Gravatar Cache
  • FV Testimonials

Free Tools

  • Pandoc Online
  • Article spinner
  • WordPress Password Finder
  • Delete LinkedIn Account
  • Responsive Design Calculator
Foliovision logo
All materials © 2025 Foliovision s.r.o. | Panská 12 - 81101 Bratislava - Slovakia | info@foliovision.com
  • This Site Uses Cookies
  • Privacy Policy
  • Terms of Service
  • Site Map
  • Contact
  • Tel. ‭+421 2/5292 0086‬

We are using cookies to give you the best experience on our website.

You can find out more about which cookies we are using or switch them off in .

Powered by  GDPR Cookie Compliance
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Necessary Cookies

Strictly Necessary Cookie allow you to log in and download your software or post to forums.

We use the WordPress login cookie and the session cookie.

If you disable this cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.

Support Cookies

Foliovision.com uses self-hosted Rocket.chat and self-hosted Freescout support desk to provide support for FV Player users. These cookies allow our visitors to chat with us and/or submit support tickets.

We are delighted to recommend self-hosted Rocket.chat and especially Freescout to other privacy-conscious independent publishers who would prefer to self-host support.

Please enable Strictly Necessary Cookies first so that we can save your preferences!

3rd Party Cookies

This website uses Google Analytics and Statcounter to collect anonymous information such as the number of visitors to the site, and the most popular pages.

Keeping this cookie enabled helps us to improve our website.

We reluctantly use Google Analytics as it helps us to test FV Player against popular Google Analytics features. Feel free to turn off these cookies if they make you feel uncomfortable.

Statcounter is an independent Irish stats service which we have been using since the beginning of recorded time, sixteen years ago.

Please enable Strictly Necessary Cookies first so that we can save your preferences!