Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Improving the plugin q2a-caching (by bndr + sama55 + stevenev)

0 votes
asked Jun 20 in Plugins by q2apro
edited Jun 21 by q2apro

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
answered Jun 21 by q2apro
edited Jun 21 by q2apro

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.

commented Jun 22 by Scott
What do you mean by “file caching”? What files exactly are you caching?
commented Jun 24 by q2apro
The qa_content output (i.e. the complete HTML page) is saved as a file. With the plugin it does not have a file ending (if you open it, it is an HTML file). Instead from the DB, the content is then loaded statically from the file (file system).