It took me a while but I finally figured out a good caching solution and worked around the various issues. The changes are now on the 1.8 branch on GitHub for anyone that wants to help test it.
Be warned: this is beta code! It may not be suitable for production use on live websites. Also note that if you upgrade from 1.7, you won't be able to downgrade again due to changes in how user passwords and IPs are stored.
But if anyone is able to try it either on localhost or a separate test install on their server, it would be much appreciated. I will be doing some testing on my own server.
To enable caching, the following steps need to be taken:
- Make a folder to store the cache files and chmod it to 777. Note: for security reasons the folder must be outside your document root. In other words you must not be able to view cache files in your browser like example.com/cache/123abc456def
- Set the QA_CACHE_DIRECTORY constant in qa-config.php to the location you made above (see qa-config-example.php for an explanation).
- Go to Admin > Caching and tick "Enable caching".
Currently, question caching only applies for logged-out users. The vast majority of visits to my site were not logged in, I think that will be typical for most sites. The following things are cached:
- Question data (answers, comments, etc) for all questions older than 7 days.
- Related questions widget
- Category widget
There is plenty more that can be cached, such as question lists, users page and tags page, but the above are by far the most common queries.
If you find any problems please post an answer with details. Thanks!
UPDATE: I've found a small issue with the upgrade queries when using a shared user base (the QA_MYSQL_USERS_PREFIX option). Will fix asap. Now resolved.