How to enable even lighter weight server polling

Epoch polls your server at a configured frequency (the default is 15 seconds) to see if new comments are available. The request looks like this:

Epoch: Hey server, how many comments are there for post #45?
Server: There are 17 comments.

...Fifteen seconds later....

Epoch: Hey server, how many comments are there for post #45?
Server: There are 17 comments.

...Fifteen seconds later....

Epoch: Hey server, how many comments are there for post #45?
Server: There are 18 comments.
Epoch: Oooh! A new comment! Please send me the contents of comment #18.

This transaction keeps things very lightweight. Then only data sent between the browser and the server is a number. The number of comments. But, it'd be a lot better if we didn't have to hit a database and load WordPress to generate that number.

This got us thinking...

If all we need is a number, why bother hitting the database and loading WordPress to get it? Let's just store the number on the server and hit it as a txt file. It's low tech. Stupidly simple... but your server and web host will love it. Thousands of database hits add up to substantial load. Hitting txt files thousands of times is so much kinder.

How to enable txt-based server polling in Epoch

Define EPOCH_ALT_COUNT_CHECK_MODE in your wp-config file. Like this:

define( 'EPOCH_ALT_COUNT_CHECK_MODE', true );

What will happen

  1. Epoch will create a new folder in your wp-content/uploads folder. It'll be named epoch.
  2. Epoch will generate a txt file for each post one your site. The contents of the txt file will be a constantly updated number which shows the number of comments for that post. It's pretty simple. 

A bonus

Since hitting txt files is such a low-level server function your web host probably won't blink. Go ahead and reduce the polling time in Settings > Epoch down to 5 or so seconds. It should be fine. Check with your host if you aren't sure.

Some caution

This may or may not be supported by your host, depending on their security settings. It is completely secure but hosts with overly-cautious file-writing permissions may not allow it. Give it a try and see what happens. 

Still need help? Contact Us Contact Us