Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
in Plugins by
edited by

I am trying the q2a-caching plugin which saves the output into the filesystem and reads it from there.

Github: https://github.com/stevenev/q2a-caching

It seems to work great, as it reduces my mysql process from 86 % to 26 % load. Awesome.

However, it seesms that the plugin is removing the entire file cache on an event happening.

1. Incoming event triggers clear_cache(): https://github.com/stevenev/q2a-caching/blob/master/qa-caching-event.php#L16

2. clear_cache() deletes entire cache: https://github.com/stevenev/q2a-caching/blob/master/qa-caching-main.php#L134

I am pretty sure that this is not necessary. Instead, we should get the postid from the event and only remove this specific cached site/file. But not the others.

Any ideas how to do the caching better?

Q2A version: 1.8.0

1 Answer

0 votes
edited by

Alright, I have changed the original plugin so that it caches only questions.

Each question gets updated when there is a change to it, such as answer added, edit, upvote etc.

It's beta, so please test it and report back: https://github.com/q2apro/q2apro-caching

You need to create a folder /qa-cache in your root. – The names of the cache files are the questionids!

The other versions of the plugin work well, however, they empty the entire file cache on incoming events. This plugin here only deletes the specific question page if it gets changed. So basically it should be more performant. Testers needed :)

Thanks for any feedback.

Cleared the cache and tried. Yes, it's working perfectly. Good job
edited by
On snow flat theme on mobile, the votes ( number of votes) position is dislocated if it is zero while showing cached page. Answers number on related questions is also misplaced if the number of answer is zero.
Probably the theme uses two different CSS files? In the recent plugin version I commented-out the part for this, enable it again: https://github.com/q2apro/q2apro-caching/blob/master/qa-caching-main.php#L430

return QA_CACHING_DIR . '/' . $md5 . ( $this->mobile? '_mobile': '_desktop' );

This should fix it.
Another problem with pagination. If our question has many answers then the next page button won't work on this cached page.