Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
1.4k views
in Q2A Core by
edited by
We are working on a cache system for q2a.  I think it is a good time to propose a general q2a cache in mysql, as part of core, that all plugins can use.

Fields:

id:  Sequentially incrementing id

owner:  module or plugin that owns the cache entry

type:   set by owner

idx:    The index to the record

idx_crc32:  crc32 hash of the idx, this is done for performance, so we only use the crc in our large index.  e.g. for url caching, the url is very long, so we don't index it, instead index crc32 of the url.

last_updated_time

content:   text or blob

index for above:

composite of owner, type, idx_crc32
Q2A version: 1.7
by
It is good idea. When we fixed this problem, it might be realized. http://www.question2answer.org/qa/46377
by
This might help a bit: http://meta.stackexchange.com/questions/69164/does-stack-exchange-use-caching-and-if-so-how "Virtually all pages accessed by (and subsequently served to) anonymous users are cached, whole cloth, via Output Caching."
by
Thank you @q2apro.  Amazing read.  Yes, soma55's is doing the same thing, via output caching for anonymous users.  The tricky part is invalidating cache when things change, themes change, etc. but the plugin is coming along pretty good considering all those complexities.
by
Sidenotes to be considered:
1. Even anonymous users could answer. Then we would need to load the editor (plus the security token).
2. I am using the liveticker widget, for instance, which is displayed on each side. It would become static and not "live" anymore. (It loads the latest forum events on each site load).
by
Cache plugin will display same (cached) HTML to users who are not logged in. And, basically it does not recognize anonymous user based on IP (cookie). Therefore, features for anonymous user will be severely limited. For example, Q2A allow anonymous posting by default. And, anonymous user can edit / close / hide own content. In this plugin, anonymous user can post. But, he can not edit / close / hide own post. Users do not like this specification would not use my plugin. If your plugin required login, it might work correctly. Vice versa, if your plugin do not require login, it might not work correctly. In other words, both plugins will not be compatible. This plugin is very powerful, but do not forget that it is a limited functionality.
by
@sama55, if anon users interact with the form and submit something, plugin could easily put a flag in the session and no longer show cache to that users.

I believe this plugin can/should achieve 100% functionality except for live ticker?
by
> if anon users interact with the form and submit something, plugin could easily put a flag in the session and no longer show cache to that users.

Yes. When POST or PUT is requested, normal processing will be performed.

> I believe this plugin can/should achieve 100% functionality except for live ticker?

I also want to cover much range. However, when we apply cache plugin, the same HTML is returned to multiple users. So, some plugins that use IP to identify the user and return variable response might not move correctly. This is the limit of cache mechanism. Anyway, by performing binding test, compatibility with several plugins will become clear.
by
> Yes. When POST or PUT is requested, normal processing will be performed

I think we need to do more.  Since a anon user might click on a few more pages, and then decide to edit their post.  This means that we need to put the flag in session to no longer show them the cached copy, otherwise immediately after the post page, the history is lost

> some plugins that use IP ..
yes, true
by
> I think we need to do more.  Since a anon user might click on a few more pages, and then decide to edit their post.  This means that we need to put the flag in session to no longer show them the cached copy, otherwise immediately after the post page, the history is lost

Can you realize how it in the cached state? When you show program for your hope to me, I'll adopt it.
by
edited by
Working on it...
by
It is working. Please see my branch, specifically https://github.com/sama55/q2a-caching/commit/d328fac81e6bf577d10f274fc0b6429563311f16 related to: $_SESSION['cache_use_off']

There should be a more elegant way than the logic added to qa-plugin.php - maybe you can make that change.
by
Your research is good. There will be also relationships. And I was also carelessly.  But, as you wrote in the title, this thread is a proposal to core or core developers. Discussion about my plugin should not be here. If Q2A core has been developed even now, and core developers are interested in this discussion, they will comment or answer.

1 Answer

0 votes
by
Mysql general cache table could easily be a plugin.  I am thinking about developing it. Fairly easy.
...