Lets all brainstorm to get this thing done.
Few considerations:
1- Ideally we need to cache every single page( question pages, front page, list views, user pages, ) except admin-only pages
2- Each time an event fires, cache copy of pages affected by this event have to be updated.
3- Plug-ins also have to get notified of this cache page updates.
Two very typical scenario:
Scenario 1. A user answers a question.
- As a result his/her score has to be updated in his/her user page, the activity page, the question page, the questions list page, walls of other users if he/she has posted anything.
Scenario 2. Each time a page gets visited, its cached version has to be updated too. why? because page views are displayed in question pages at the top.
In one word, each time there is an update/write to db, the corresponding cached pages have to be updated too (except the admin ones) .
Very expensive to implement right?
Suggesting approach:
so we need to lower our expectation and only concentrate on updating caching for more important stuff and leave some of the components to be later read and updated via ajax calls (e.g. users scores, page views, votes etc)
convention:
- Lets call important stuff like questions, answers, comments and the scaffoldingof the page (related CSS and HTML DOM) class 1 component
- Lets call user scores, vote values, flag values etc, class 2 components
Example: For a question page, the question itself, the answers, the comments to be cached and leave the rest to be updated by ajax calls only after entire page is fully loaded ( from cache copy).
1- Each time a question or answer or a comment is posted/updated (class 1 components changed), update the cache of corresponding pages.
Updating or creating a cache for a page means: rendering entire page (class 1 and class 2) and storing them all together as cached copy
2- Each time a page is requested:
if (the cache copy of that page is available)
{ -load cache copy (the class 1 components which are up to date and correct + cached copy of class 2 which might not be up to date )
- update class 2 components like users scores, votes, flags by ajax calls
e.g. the users sees the entire page loaded quickly and notices that the user A had score 85, but after 1-2 second his/her score get updated to value 93.
}
else {
- load class 1 components of the page from db
- update class 2 components by ajax calls to db
- update the cache copy of that page
}
I "think" this approach can also take care of complications the third party plugins add too
Question: is this possible?
----------------------------------------
Please kindly avoid posting comments like, it is not that easy, it needs time etc. Instead try to contribute please